Difference between revisions of "Python Starting"

From Computer Science
Jump to: navigation, search
(Python Online)
(Connect to the CS Server)
Line 8: Line 8:
  
 
=Connect to the CS Server=
 
=Connect to the CS Server=
The CS server has python installed. If you have an account for the CS systems (see [[CS Accounts and CS Lab Computers]]) then you can use this account to login to the CS server and run Python in the terminal.  See [[CS Server - Terminal]] for how to connect to the CS server.
+
The CS server has python installed. If you have an account for the CS systems (see [[CS Accounts and CS Lab Computers]]) then you can use this account to login to the CS server and run Python in the terminal.  See [[CS Server - Terminal]] for how to connect to the CS server.  Once you are logged into the server, you can run python in interactive mode by simply running: <code>python3</code>
 +
 
 +
To run a python program that is in your account on the server, you would run: <code>python3 filename.py</code> where <code>filename.py</code> is the name of the file you want to run.
 +
 
 +
Note that the <code>python</code> might be running an older version of python (python2). You can tell by running this command: <code>python --version</code>
 +
 
 +
If this prints a version that is 2.something, you should use the command python3 to make sure you are using the current version of python (as above).

Revision as of 17:00, 20 August 2022

To get started with Python programming, you need to be able to run the program. Here are some ways to get started...

Install Python

You can install python on your personal computer. You download from python.org/downloads, and it normally auto-detects your OS. Click the download button, install it, and open it open after it's installed.

Python Online

There are various websites that provide an online Python environment that you can use in your web browser. Most of these are fine to use to get started. One that we are familiar with that you could try is repl.it.

Connect to the CS Server

The CS server has python installed. If you have an account for the CS systems (see CS Accounts and CS Lab Computers) then you can use this account to login to the CS server and run Python in the terminal. See CS Server - Terminal for how to connect to the CS server. Once you are logged into the server, you can run python in interactive mode by simply running: python3

To run a python program that is in your account on the server, you would run: python3 filename.py where filename.py is the name of the file you want to run.

Note that the python might be running an older version of python (python2). You can tell by running this command: python --version

If this prints a version that is 2.something, you should use the command python3 to make sure you are using the current version of python (as above).