Program 1 - Installing and Using Python

In this assignment you will write your first Python program. Your program should print out a sentence like this:

My name is Carol Ono and I am taking ECS 10 because it is required for my major.

It has to include your name (so unless your name is Carol Ono the sentence your program prints should be different from the example sentence above), and the phrase "...and I am taking ECS 10 because...". Feel free to tell us the real reason you are taking this course. There will be no retribution.

But, just to make it hard, you program MAY NOT include either a "1" or a "0". So a program that included the statement below would lose points:

print "My name is Carol Ono and I am taking ECS 10 because it is required for my major."

Where to do the assignment

You can do this assignment either in the lab or on your own computer, if you have one. If you do the assignment in the lab, note that to get to IDLE you choose "Class software", then "Python 2.5", 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 hours and we would be happy to help you install Python. 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, and name it "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.

For instance, running my version of the program makes this appear in the IDLE window:

>>> ================================ RESTART ================================
>>>
My name is Prof. Amenta, and I am teaching ECS 10 because I taught it last year and I had a pretty good time.

Handing in the program

We will use myUCDavis to hand in assignments. Enter myUCDavis and select ECS 10 from your list of courses on the right. Left-click "Assignments" near the upper left, and then "Project 1". Click on "Drop-Off" and then "Browse". Get to your Desktop, and then to the "ECS 10" folder you made, and finally select your file "prog1.py". The file name "prog1.py" should appear in the box next to the "Browse" button. Click "drop-off" to hand in your program.

Do NOT hand in a screenshot of your program's output. Do NOT hand in a text file containing the words "My name is Carol Ono...". We want the file containing your Python program, which we will run when grading.

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 personal file storage area on myUCDavis. To save it on flash-drive,a 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.