Difference between revisions of "Python Starting"

From Computer Science
Jump to: navigation, search
(Connect to the CS Server)
(Reading and Tutorials)
Line 25: Line 25:
 
The following are good sources to read when starting out with python. If you are taking a course at ISU that uses python, the course might use one or more of these as required reading material.
 
The following are good sources to read when starting out with python. If you are taking a course at ISU that uses python, the course might use one or more of these as required reading material.
  
* [https://docs.python.org/3/tutorial/ Python.org tutorial] - good for those with programming experience already, or in a course where the instructor is guiding the class
+
* [https://docs.python.org/3/tutorial/ Python.org tutorial] - the official python documentation, good for those with programming experience already, or in a course where the instructor is guiding the class
 
* [https://www.w3schools.com/python/python_intro.asp w3schools Python] - interactive tutorial where you can try out code in the browser
 
* [https://www.w3schools.com/python/python_intro.asp w3schools Python] - interactive tutorial where you can try out code in the browser
 
*  [https://www.learnpython.org/ Learn Python] - interactive tutorial where you can try out code in the browser
 
*  [https://www.learnpython.org/ Learn Python] - interactive tutorial where you can try out code in the browser

Revision as of 18:54, 20 August 2022

Running Python Programs

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. You can use the built-in text editor that is installed with Python (IDLE), or you can use a different text editor for editing your python files.

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. For example, you can do the following.

cd ~                                  # make sure you are in your home directory
cp /net/web/code/python/hello.py ./   # copy hello.py to your directory
python3 hello.py                      # run the program

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 (e.g., 2.7.18), you should use the command python3 to make sure you are using the current version of python (as above).

Note that if you plan to use the terminal and CS server to do your development, then you will also need to be familiar with using one of the text editors that works in the terminal (Linux Terminal - Text Editors).

Reading and Tutorials

The following are good sources to read when starting out with python. If you are taking a course at ISU that uses python, the course might use one or more of these as required reading material.

  • Python.org tutorial - the official python documentation, good for those with programming experience already, or in a course where the instructor is guiding the class
  • w3schools Python - interactive tutorial where you can try out code in the browser
  • Learn Python - interactive tutorial where you can try out code in the browser
  • Automate the Boring Stuff with Python - suitable for people with very limited programming experience, this is the text that is being followed for our CS 151 course (as of 2022)
  • Think Python - suitable for people with very limited programming experience, not very deep
  • LearnXinYminutes - quick review once you are familiar with the basics