Instructions for downloading the Python interpreter
and the Idle IDE (Integrated Development Environment).
the IDE will enable you to compile, debug and run your programs
by chosing menu options. For instance, if you make a compilation
error, Python displays the error messages.
DOWNLOADING THE Python BUNDLE for a PC
- Go to the Python download URL:
https://www.python.org/downloads/
- Click Download
- Under "also look at the detailed Python 3.4.3 page" click the Python 3.1
Windows Installer link.
- A window labeled Opening python-3.4.3.msi. Click Save File
- After the download is complete, a dialog box will open asking
"Would you like to save this file?", click Save file
- An icon labelled "python-3.1" for release 3.1 will appear on the
screen. (Perhaps a more recent release will appear.)
- When you click the icon, the computer will ask "Do you want to run this
file?", Click the run button.
- In the setup box, the option "install for all users" will have a circle
with a period in it. Click the next button.
- A box asking you to select destination directory with the proposed
directory Python34. Click the next button.
- In the next dialog box (Customize Python 3.1), click the next
button.
- Finally, click finish.
To get the IDE icon on the screen, go to Start/All Programs/python 3.4.
A small window will appear to the right with IDLE(PythonGUI). Drag
IDLE(PythonGUI) to the screen (it's called the
desktop).
DOWNLOADING THE Python BUNDLE for a Mac Using the Official Site
- Go to the Python for a MAC download URL:
https://www.python.org/downloads/
If this site is not available, go to
instructions below.
- Click Download on the left and you will be taken to a window with
Download Python
- Under "also look at the detailed Python 3.1.2 page" click the
Python 3.4.3 Mac OS X Installer Disk Image (for Mac OS X 10.3 through 10.10)
- A window opens indicating that you want to open python-3.4.3.dmg,If
the Save fileacircle does not have a dot, click it. Then click OK.
- The download window will open. Click the icon.
- In a short while, Install Succeded will appear.
Ckick the close button.
- On the desktop or in the Applications folder in the Finder,
click Python 3.4 and then the Idle icon.
DOWNLOADING THE Python BUNDLE for a Mac Using another Site
- Go to the Python for a MAC download URL:
http://download.cnet.com/Python/3000-2247_4-6565.html?tag=mncol
- Under Python 3.4 for Mac, hit the green button to the left of
Download Now.
- In the Downloads window, you will see Python 3.4 being
downloaded.
- After the download is completed, a Python 3.4 window will appear,
double click the Python.mpkg icon.
- Continue clicking in the affirmative (either the Continue or the
Agree button).
- At some point, the computer will direct you to Select aDestination
. Click the Macintosh HD icon and then the
Continue button.
- In the Install Python window click Install.
- You may then be asked for your password. If so, type it and hit OK.
- Then, hopefully you will see Install Succeeded on the screen.
Ckick the close button.
- On the desktop or in the Applications folder in the Finder,
click Python 3.4 and then the Idle icon.
Using Python as a Calulator
- Double click the IDLE(Python GUI) icon and a screen will appear with
the >>> prompt. This is called the Python shell. You can type any
expression you want, e.g.,
3*4 - 5, hit Enter, and the result, 7, will be displayed. The operator
for taking the mod is //.
- You may use branching and loop statements too, e.g.,
- doggy = True
- if doggy : # the ":" indicates the end of the if and the "#" is a comment
- ...print("NYU") #because of the ":" the print will be indented.
Then hit Enter.
Using Python to Save Programs
In order to save a program, you must write a method
:
- In the shell, on the File menu, select New window and a new window
will appear.
- Start by writing def followed by the name of your
method, let's call it fibo. The method name must be followed by a "():".
the ":" will automatically indent the next set of statements.
- When you are finished writing your statements, go to the File menu and
select Save as and save it as, let's say Prog1.py. The .py extension
stands for Python. Python will inform you if you have made an error.
- Then on the Run menu, select Run module. You are then
transferred to the shell.
- In the shell, type fibo() and your program will be executed.
Running a Program Simply by Selecting Run Module
To run a program simply by selecting Run Module:
- Add another method called main() to your original method and have
main() call fibo().
- End you program by writing "main()" at the end of your program,
Your program should look something like
:
def fibo():
a = 2
b = 3
print(a*b)
def main():
fibo()
main()
After you select Run Module, your program should run in the shell
without you doing anything else.
Samuel Marateck
Aug 31 EDT 2001, revised June 15 2015