Activity 9


Part A: Using IDLE as a Tool

During this course you will use both your textbook, and IDLE (Integrated DeveLopment Environment) as a tool to write and explore Python code.  IDLE is a free IDE (Integrated Development Environment) of the Python programming language.  While you will not explore ALL of IDLE during today's lab, we want to get started so you have a little bit of a feel for how things work.

  1. Assuming that you are sitting at a Windows computer, launch IDLE  by selecting "Start | All Programs | Python 3.3 | IDLE (Python GUI)"
  2. When IDLE starts up it should look like this:


The good news is that it will look like this whether you are in the labs on a Windows machine or at home on your Windows, Mac, or Linux based machine.  Please remember that Python is free to download and you SHOULD install version 3.5 or higher on your computer at home if you have the option!  (Download from


This is Python's interactive mode window (often called "the shell").  In this mode of working with Python you can type in almost ANY valid Python statement at the prompt (the ">>>").  When you do so, and then hit the Enter key, you send that command off to the Python interpreter to be converted to machine language and then executed (assuming that it had proper syntax and the semantics were meaningful to the interpreter).


Let's try some very basic commands.  In this shell window, at the command prompt type

print("Hello World!") 

When you hit Enter, IDLE goes off to interpret what command(s) you gave it.  In this case, it interprets your command as an instruction to print (to the screen, not the printer) whatever message is included inside of the parentheses and quotes (in computer vocabulary we normally refer to the message between quotes as a String).


What happens after you press the Enter key? (be very specific)


Let's try another commands.  At the prompt type:

1 + 2 


What happens after you press the Enter key? (be very specific)




Of course, if you typed something into the shell that IDLE doesn't recognize, you will get an error message.  To demonstrate this, type:

prin("Hello World!")

(notice that I mis-spelled print).  This gives you a message that should say something like:

Whenever you get a message like this, pay close attention to what I ASKED you to type and what you ACTUALLY typed.  While sometimes I might have a mistake in my lab, more often, you will have made a typo.



Activity  B : Writing a simple program

Suppose you needed to perform mathematical calculations to calculate information about a particular sphere.  If you remember your high school Geometry class you will remember these formulas are:

Let's look at how we might write the instructions to calculate the circumference of a sphere.

  1. We need to know the radius of the sphere.
  2. We need to calculate the circumference using the formula above
  3. We need to print out the results

We want to have the programmer write an algorithm, translate it to a working program, and than allow the user to run our program (in this context, called a script).

In the python shell window open a new programming window by selecting "File | New Window"

In this window type in the Python program below which calculates a sphere's circumference from a provided radius. 



When you have typed this in make sure that you save it.  I would suggest saving it to your flash drive as "" (since that's what the comment at the start of the program says it will be called.)

When you are ready to run this program, select  "Run | Run Module"  (notice you can achieve the same result by pressing the F5 key)


Ok, this was a GREAT start, but we know that we can get it do to much more.  After you get this working properly you should add in code to calculate and print information about the :

You should not only make sure that your program loads and runs, but you should make some calculations by hand to confirm that you are producing the correct results. 

[SIG1]  When you are happy with your results from Activity B, raise your hand and demonstrate your program.


Activity  C : You create one from scratch

You are planning a trip to Europe.  Your bank will exchange US Dollars for Euros at the rate of 0.7381 plus a $10 service fee.  This means that if you give them $110 they will give you 73.81 in Euros.  If you give them $500 they will give you 361.67 Euros.

Write a script, in a file called, that:


To get a new file in IDLE select "File | New Window"  This will launch a blank code editor. 

[SIG2]  When you are happy with your results from Activity C, raise your hand and demonstrate your program.