Class runs Jan 7-25; Lectures MTWRF 11AM-12PM in 34-101
The 1st generation AirPods are fully compatible with iPhone, iPad, and iPod touch models with iOS 10 or later, Apple Watch models with watchOS 3 or later, and Mac models with macOS Sierra or later. The 2nd generation AirPods are fully compatible with devices running iOS 12.2 or later, macOS Mojave 10.14.4 or later, and watchOS 5.2 or later. Find games for macOS tagged Idle like Luck be a Landlord, Pyramid Builder, Tree Team, plant daddy, Worldwide Arts Society on itch.io, the indie game hosting marketplace. Cheryl, feel free to submit a patch since I have less exposure to IDLE code. I can manually test the PR on my Mac and report back since this seems to be a Mac specific patch. It would be helpful if someone with access to other Mac OS versions can possibly test this so that it doesn't cause issues on other versions.
Home | Materials | Resources | Calendar | Tutor | Piazza
Getting Started: Python and IDLEWith a thousand thanks to 6.00 for use of this handout
Introduction
This handout will cover how to set up Python and introduce you to IDLE, thePython development environment we will be using throughout this course.
Setting up Python
On Athena / Linux
Python should be set up correctly on the Linux athena machines. Type'idle' at the command prompt to ensure that everything isworking correctly. This should start up the Python developmentenvironment IDLE.
On your own machine
If you are working on your own machine, you will probably need toinstall Python. We will be using the standard Python software, available here. You shoulddownload and install version 2.7.3, NOT 3.X. All MIT Course 6 classes currently use Python 2.7.
Windows:
Download and install: Windows Installer
Download and install: Windows Installer
Mac OS X:
Download and install: Mac OS X Installer.
Download and install: Mac OS X Installer.
Other Linux:
Check which version of Python you have by running
python -V
at a terminal. If you have a newer version of Python, you can set Python 2.7 as the default. If you need help with this, ask a TA. Otherwise, you should be able to do one of the following options:if you don't already have Python 2.7 installed; if you do, runto install Idle for Python 2.7. If you have Python and Idle installed with a newer version of Python (eg Python 3.X), you'll want to instead run these two commands to install the correct version of Idle:You should then be able to run Idle by simply running
idle&
from the command prompt. If you would rather compile from source, visit the Python 2.7.3 release page for compressed tarballs. If you're having problems, please ask an LA for assistance.
Check which version of Python you have by running
python -V
at a terminal. If you have a newer version of Python, you can set Python 2.7 as the default. If you need help with this, ask a TA. Otherwise, you should be able to do one of the following options:if you don't already have Python 2.7 installed; if you do, runto install Idle for Python 2.7. If you have Python and Idle installed with a newer version of Python (eg Python 3.X), you'll want to instead run these two commands to install the correct version of Idle:You should then be able to run Idle by simply running
idle&
from the command prompt. If you would rather compile from source, visit the Python 2.7.3 release page for compressed tarballs. If you're having problems, please ask an LA for assistance.
Warning: On the Python homepage, thelatest version available for download is actually 3.X. Do not installthis! This version is not backwards compatible with the code thatyou'll be writing in this course (for example, you have to typeprint('test') instead of print 'test'). Instead, be sure to downloadthe version listed above.
Using IDLE
IDLE is the standard Python development environment. Its name is anacronym of 'Integrated DeveLopmentEnvironment'. It works well on both Unix and Windows platforms.
It has a Python shell window, which gives you access to the Pythoninteractive mode. It also has a file editor that lets you create andedit existing Python source files.
During the following discussion of IDLE's features, instead ofpassively reading along, you should start IDLE and try to replicatethe screenshots.
Interactive Python shell
When you start up IDLE, a window with an interactive Python shell willpop 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:
and pressing ENTER, will cause the following to be displayed:hello world |
IDLE can also be used as a calculator:Addition (+), subtraction (-), multiplication (*), division (/), modulo (%) and power (**) operators are built into thePython language. This means you can use them right away. If you wantto use a square root in your calculation, you can either raise somethingto the power of 0.5 or you can import the math module. Do not worry about what it means right now, we will cover this later during the course. Below are two examples of square root calculation:
>>> 16**0.5 4.0 >>> import math >>> math.sqrt(16) 4.0 |
Exercise
(this is just for practice, solutions will not be graded or collected in class)Use IDLE to calculate:
Idle 42 Mac Os X
- 6+4*10
- (6+4)*10 (Compare this to #1, and note that Python uses parentheses just like you would in normal math to determine order of operations!)
- 23.0 to the 5th power
- Positive root of the following equation:
34*x^2 + 68*x - 510
Recall:
a*x^2 + b*x + c
x1 = ( - b + sqrt ( b*b - 4*a*c ) ) / ( 2*a)
--------
The tutorial for IDLE is based on the official IDLEtutorial by Daryl Harms.
The tutorial for IDLE is based on the official IDLEtutorial by Daryl Harms.
Idle 42 Mac Os Catalina
Asfandyar Qureshi, Feb 2006.
Edited by Vladimir Bychkovsky, Sept 2006.
Edited by Calvin On, Feb 2007.
Edited by Yang Zhang, Sep 2008.
Edited by Chih-yu Chao, Feb 2009.
Edited by Sari Canelake, Dec 2009.
Edited by Vladimir Bychkovsky, Sept 2006.
Edited by Calvin On, Feb 2007.
Edited by Yang Zhang, Sep 2008.
Edited by Chih-yu Chao, Feb 2009.
Edited by Sari Canelake, Dec 2009.