08 - Raw Input

Watch the following video, and do the examples shown in the video as they are demonstrated.

Assignment

Write a program that prompts for your name and year of birth, then calculates your age (using the current year) and outputs a statement similar to:

Bob, you are 16 years old.

Save as 08_Input.py.

Notes from the video

input() with a string returns an error

use input() for entering numbers

use raw_input() for entering strings

Program Headers

All programs should include a “program header”. This header should, as a minimum, include the author’s (programmer’s) name, the date, the filename, and a program description. An example header is shown below:

# author: Jane Doe

# date: 2012-03-26

# filename: 08_Input.py

# description: prints user’s name and age to the screen

Note that a "#” sign is used before each of the header lines. These are used to tell the program to ignore these lines and treat them like comments.

For most programs written in this class, you may copy and paste the program requirements into the "description" part of the header. If it is too wide to fit on the screen, break it up into two or more lines.

All programs (including this one) must be submitted with a suitable program header.

09 - Sequences and Lists