Skip to the content.

In-class activity: Run a Python program in IDLE

  1. Install Python on your own computer from python.org – look for the Downloads link.
    • You must use a computer, not a tablet.
    • If you don’t have your own computer available in class, work with a partner in class and complete this activity later on your own computer.
    • If you don’t have access to a computer at all, notify the instructor. It is possible to borrow a laptop from Dickinson for the semester if necessary.
  2. We will be using a program called IDLE for writing and executing Python programs. IDLE was automatically installed when you installed Python. Open IDLE on your computer now.

  3. Use File | New File to create a new file. This will be a Python source code file containing our first Python program. Python files should have a name that ends in .py. Before typing the program in, save the file using File | Save As.... Name the file greetings.py, and save it in your class01 folder on OneDrive.

  4. Type or paste this Python code into your file:
    print("Greetings. I wonder if COMP130 will be fun AND useful AND enriching.")
    
  5. Save the file, then run the program via Run | Run Module.

  6. If you have time, paste in more code and experiment with it. For example, try this:
topic = input('What is/was your first year seminar topic? ')
print('Nice!!', topic, 'sounds interesting.')

Or this:

import math
x = math.sqrt(2)
print("By the way, did you know that the square root of 2 is", x, "?")

Or this:

a = 7
b = 24
c = a + b
print("Also, the sum of", a, "and", b, "is", c)

Don’t worry if you don’t understand the code. We’ll learn all about it this semester.