Lab 2: Next step

Once again we have labs and classes a little out of balance because of Holidays and the loss of our first Monday. (We can all take a moment to appreciate the fruits of the labor movement (the true meaning of Labor Day): the 8-hour work day, weekends, and child labor laws.)

So for the second lab running we will actually introduce NEW material rather than practice OLD material.

Asking for input

Last week we learned that there are such things as variables and we can put values into them. We also learned that we can evaluate some basic math expressions. Now I want to show you the function input which asks the user for keyboard input.

If you run that code you'll be asked for your birthday, and what you enter will be displayed.


Please make a file named in a cloud9 workspace, save those lines into the file. Then from bash (the terminal) execute it with the line python3

Save the URL of this cloud9 workspace for your submission.


The input is saved as a string, if we want to do some math on a user's input we need to cast the input into an int. This is a new term, but to cast a variable into a different type is to ask the computer to now see it differently.

Here, have an example. First predict what you think might happen, then click RUN, then think about why it happened that way. How does that dumb computer think?


Build a program which asks the user for a number. Then asks the user for another number. Then display the average of the two numbers on screen. Email this cloud9 URL and the URL in your lab report.