6.00: Introduction to Computer Science and Programming

Problem Set 0

Handed out: Thursday, September 10, 2009.
Due: 11:59pm, Tuesday, September 15, 2009.

Introduction

This problem set will introduce you to the programming environment IDLE and to programming in Python, as well as to our general problem set structure.  In this problem set, you will install IDLE, write a simple Python program, and hand it in. Be sure to read this problem set thoroughly, especially the sections of Collaboration and the Handin Procedure.

Collaboration

Please take note of the collaboration policy as stated in the course information handout.

Installing Python and IDLE

Follow the steps in the Getting Started: Python and IDLE handout for installing Python and IDLE onto the machine you plan to be using this term.  You may skip the installation step if you are working on an Athena machine.


Familiarize yourself with Python and IDLE using the exercises given in the handout.  Once you are ready, proceed to the programming part of this assignment.


Note, when you first start using your system, make sure that the version number displayed is not 3.0 or higher.  That version of Python is not backwards compatible with 2.5.4, which is the official Python version used in this course.

A Very Simple Program: Entering and Printing Your Name

The goal of this programming exercise is simply to get you more comfortable with using IDLE, and to begin using simple elements of Python.  Standard elements of a program include the ability to print out results (using the print operation), the ability to read input from a user at the console (for example using the raw_input function), and the ability to store values in a variable, so that the program can access that value as needed.

Problem 1.

Write a program that does the following in order:

Asks the user to enter his/her date of birth.

Asks the user to enter his/her last name.

Prints out the user’s last name and date of birth, in that order.

An example of an interaction with your program is shown below (the words printed in blue are from the computer, based on your commands, the words in black are a user’s input – the colors are simply here to help you distinguish the two components):

Enter your date of birth: 
**01/26/32
Enter your last name:
**Grimson
Grimson 01/26/32

Hints:

To see how to use the print command, you may find it convenient to look at the input and output section of the Python Wikibook.  This will show you how to use print statements to print out values of strings.

To see how to read input from a user’s console into the Python environment, you may find it convenient to look at the same section (see for example the raw_input function).

Remember that if you want to hold onto a value, you need to store it in a variable (i.e., give it a name to which you can refer when you want that value).  You may find it convenient to look at the variables and strings section of the Python Wikibook.

Hand-In Procedure

1. Save

Save your code in ps0.py. Do not ignore this step or save your file(s) with different names.

2. Time and Collaboration Info

At the start of each file, in a comment, write down the number of hours (roughly) you spent on the problems in that part, and the names of the people you collaborated with. For example:

 # Problem Set 0
 # Name: Jane Lee
 # Collaborators (Discussion): John Doe
 # Collaborators (Identical Solution): Jane Smith
 # Time Spent: 3:30
 # 
... your code goes here ... 

3. Submit

To submit a file, upload it to your workspace. If there is some error uploading to your workspace, email the file to 6.00-staff [at] mit.edu.

You may upload (or email) new versions of each file until the 11:59pm deadline, but anything uploaded after that will be ignored.