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.
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
asks the user for keyboard input.
Please make a file named
input.py in a cloud9 workspace, save those lines into the file. Then from
bash (the terminal) execute it with the line
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?
repl.it 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 repl.it URL in your lab