Difference between revisions of "Python Starting"
(→Python Online) |
(→Reading and Tutorials) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | =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... | To get started with Python programming, you need to be able to run the program. Here are some ways to get started... | ||
− | =Install Python= | + | ==Install Python== |
− | You can install python on your personal computer. You download from [https://www.python.org/downloads/ 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 install python on your personal computer. You download from [https://www.python.org/downloads/ 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= | + | ==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 [https://replit.com/languages/python3 repl.it]. | 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 [https://replit.com/languages/python3 repl.it]. | ||
− | =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. For example, you can do the following. | ||
+ | <pre> | ||
+ | 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 | ||
+ | </pre> | ||
+ | |||
+ | Note that the <code>python</code> command 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'' (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. | ||
+ | |||
+ | * [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.learnpython.org/ Learn Python] - interactive tutorial where you can try out code in the browser | ||
+ | * [https://automatetheboringstuff.com/ 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) | ||
+ | * [http://greenteapress.com/thinkpython2/html/index.html Think Python] - suitable for people with very limited programming experience, not very deep | ||
+ | * [https://learnxinyminutes.com/docs/python3/ LearnXinYminutes] - quick review once you are familiar with the basics | ||
+ | |||
+ | =Assignment 1= | ||
+ | Your instructor might have you complete the following assignment to make sure you are all set with running Python code on the CS server. | ||
+ | |||
+ | First, make sure you can login to the CS server from your home computer. See [[CS Server - Terminal]]. For this assignment you will visit the CS help lab (either in person or remotely from home, see [[Unix Lab and Help]]) and demonstrate that you are able to edit and run python files on the CS server. | ||
+ | |||
+ | Once you are present at the CS help lab (either in person or online with a GA), you will do the following. | ||
+ | # Share your screen (if you are connecting online). | ||
+ | # Login to the CS server with your CS class account. | ||
+ | # Create a new directory named python_demo | ||
+ | # Go into the python_demo directory and start editing a file hello.py | ||
+ | # In the hello.py file, put a print statement to print "Hello World!", and save the file. | ||
+ | # In your terminal, run the hello.py program (by running <code>python3 hello.py</code>). | ||
+ | # Edit a file called count.py, and put code in it to print out the integers from 1 to 10. Save the file and demonstrate running it in the terminal. | ||
+ | |||
+ | That is it. You will have demonstrated that you can login to the CS server, edit python files, and run them. If you have any problems, the GA can help and give you a chance to start over again to demonstrate that you can do this. | ||
+ | |||
+ | '''Pass rating check''' You need to be able to do all of this on your own without help. If you have trouble and need some help from the GA, you can try again by starting the process over. | ||
+ | |||
+ | ''Note - the shared spreadsheet that GAs use for submitting information to Jeff Kinne's courses is [https://sycamoresindstate-my.sharepoint.com/:x:/g/personal/jeffrey_kinne_indstate_edu/ESbWO8QmBg9Jn9-ufDqR6_EBPzUbhzjVjyyzAPEAcjbMgg?e=XBpLEa this link], which should work only for the current term's GAs.'' |
Latest revision as of 16:40, 28 September 2022
Contents
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
command 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
Assignment 1
Your instructor might have you complete the following assignment to make sure you are all set with running Python code on the CS server.
First, make sure you can login to the CS server from your home computer. See CS Server - Terminal. For this assignment you will visit the CS help lab (either in person or remotely from home, see Unix Lab and Help) and demonstrate that you are able to edit and run python files on the CS server.
Once you are present at the CS help lab (either in person or online with a GA), you will do the following.
- Share your screen (if you are connecting online).
- Login to the CS server with your CS class account.
- Create a new directory named python_demo
- Go into the python_demo directory and start editing a file hello.py
- In the hello.py file, put a print statement to print "Hello World!", and save the file.
- In your terminal, run the hello.py program (by running
python3 hello.py
). - Edit a file called count.py, and put code in it to print out the integers from 1 to 10. Save the file and demonstrate running it in the terminal.
That is it. You will have demonstrated that you can login to the CS server, edit python files, and run them. If you have any problems, the GA can help and give you a chance to start over again to demonstrate that you can do this.
Pass rating check You need to be able to do all of this on your own without help. If you have trouble and need some help from the GA, you can try again by starting the process over.
Note - the shared spreadsheet that GAs use for submitting information to Jeff Kinne's courses is this link, which should work only for the current term's GAs.