Install Python & IDLE
Install Python & IDLE
- Download this file: python-3.6.2.exe
- Run the file
- Choose "Install now"
- Let me know when I need to enter my Admin credentials
- the "online tutorial" link is a good one (to look through if you're waiting or save for later)
This section is from http://web.mit.edu/6.s189/www/handouts/GettingStarted.html Links to an external site.. Try the examples!
Using IDLE
IDLE is the standard Python development environment. Its name is an acronym of "Integrated DeveLopmentEnvironment". It works well on both Unix and Windows platforms.
It has a Python shell window, which gives you access to the Python interactive mode. It also has a file editor that lets you create and edit existing Python source files.
During the following discussion of IDLE's features, instead of passively reading along, you should start IDLE and try to replicate the screenshots.
Interactive Python shell
When you start up IDLE (search for IDLE in the start menu, and make a desktop shortcut), a window with an interactive Python shell will pop up:
You can type Python code directly into this shell, at the '>>>' prompt. Whenever you enter a complete code fragment, it will be executed. For instance, typing:
>>> print ("hello world")
|
and pressing ENTER, will cause the following to be displayed:
hello world
|
Try typing an underscore ( _ ). Can you see it? On some operating systems, the bottoms of hanging letters such as 'g' or 'y', as well as underscorces, cannot be seen in IDLE. If this is the case for you, go to Options -> Configure IDLE, and change the size of the default font to 9 or 11. This will fix the problem!
IDLE can also be used as a calculator:
>>> 4+4
8 >>> 8**3 512 |
Addition (+), subtraction (-), multiplication (*), division (/), integer division (//), modulo* (%), and power (**) operators are built into the Python language. This means you can use them right away. If you want to use a square root in your calculation, you can either raise something to the power of 0.5 or you can import the math module. Do not worry too much about this right now, we will cover it later during the course. Below are two examples of square root calculation:
>>> 16**0.5
4.0 >>> import math >>> math.sqrt(16) 4.0 |
The math module allows you to do a number of useful operations:
>>> math.log(16, 2)
4.0 >>> math.cos( 0 ) 1.0 |
Note that you only need to execute the import command once after you start IDLE; however you will need to execute it again if you restart the shell, as restarting resets everything back to how it was when you opened IDLE.
*Generally speaking, "5 % 7" is read "5 mod 7" or "5 modulo 7", where the modulus is 7
Your first program
- in IDLE, select File --> New File
- type this in the new blank window: print("hello world")
- select File --> Save As "hello world" and save to your python Google Drive folder
- F5 to run the program (or Run --> Run Module)