Program 1 - Installing and Using Python

In this assignment you will write your first Python program. Please write a program to print out a list of three things. For instance, my program prints:

My three favorite moderately obscure movies are:
1 Map of the Human Heart
2 American Movie
3 City of God


You can do moderately obscure movies, or anything else you'd like to list. Make your own list, don't copy mine.

The items in your list should be numbered with the digits 1, 2 and 3, just like the example above. Just to make it hard, for one more point, write the program so that it only uses the digit "4". So this program would only get 9 points out of a total of 10, because it uses the digits 1,2 and 3.

print "My three favorite moderately obscure movies are:"
print "1 Map of the Human Heart"
print "2 American Movie"
print "3 City of God"


A program that uses Roman numerals, or writes out "one", "two", "three", or whatever, also does not get full credit. Try and make a program that does not have a 1 in it, but that prints a 1 when you run it.

Where to do the assignment

You can do this assignment on your own computer, or in any of the labs in which Python is installed: 1131 Meyer, 93 Hutchinson, or 2020 Sciences Laboratory Building, or the open access lab 95 Hutchinson. If you do the assignment in one of the labs, note that to get to IDLE you choose "Class software", then "Python 2.6", and then "IDLE".

To do the assignment on your own computer, you will need to install Python. We strongly recommend you install Python, and we strongly recommend that you do it this week. If you have a laptop, you could bring it to lab for help with the installation. The book suggests that you install Python from the CD at the back of the book. Ignore this, and download it as described on the Web page. That way, you get the latest version.

Either way, we suggest you begin by making a new folder on your Desktop, called "ECS 10", where you can keep your work. To do this, put the mouse on an empty spot on the Desktop and right click, select "New" and then "Folder". When the folder appears, its name should be highlighted; type "ECS 10" to rename it.

Getting started

This is similar to the "Game Over" program in Chapter 1 of the textbook. Before you write the program, familiarize yourself with using IDLE by working through all the things that pages 7-9 suggest that you try. Actually try them. It really helps. Then follow the instructions on page 10: open a script window, type in your lines (or line...) of Python code, and then run it by selecting "Run", and then "Run Module".

If you get as far as page 14, there is an error! The magic line that makes the program pause for input is

raw_input("\n\n...

NOT

raw input("\n\n....

At this point you will be asked to save your program. Save it to your new folder on the Desktop. The name of your program should end in ".py", for instance, "prog1.py". In Windows, it will show up, in the folder, with the Python logo. The program should then run immediately, producing the output IN THE IDLE WINDOW, not in the script window.

You may include a final "raw_input()" line at the end of the program, or not. Either way is fine for this assignment. What difference does it make? (this is not a rhetorical question; I want you to think about what you program does differently with or without the "raw_input()" line).

Submitting the Assignment

We will be using SmartSite to turn in assignments. Go to SmartSite, go to ECS 010, and go to Assignments. Submit the file containing your program as an attachment.

Do NOT cut-and-paste your program into a text window. Do NOT hand in a screenshot of your program's output. Do NOT hand in a text file containing the words "My three favorite..." We want the file containing your Python program, for example "prog1.py". When grading the program, we will run click on the file and run it.

Saving your work

If you are working on your own computer, you can just leave the ECS 10 folder on your Desktop for the rest of the quarter. If you are working in the lab, you will need to take the folder with you on your flash-drive or save it to your workspace on SmartSite. To save it on flash-drive, plug the flash-drive into the computer (the staff in the computer classrooms can help you figure out how), open the flash-drive, and copy the whole ECS 10 folder onto it by moving the folder from the Desktop onto the flash-drive. To copy the file to your SmartSite workspace, go to Workspace, select Resources, and then use the Add button next to "My Workspace".