4.4. Making a MadLib story¶
You might have done MadLib stories when you were a kid. You provide some pieces of information, like a name of a friend, a verb, and a favorite game (for example), and those pieces of information get plugged into a story. Since you don’t know the story beforehand, you’re surprised at what happens to your friend in the story.
You should really do this: Run this program to see what gets generated, then change some of the variables to make different stories. Try different names, different verbs.
When you print a string (a sequence of characters in a pair of single, double, or triple quotes) in Python it will print the exact characters in the string. When you print a variable it will print the value of that variable.
Put the blocks below into the correct order to print a twist on a famous poem.
Put the blocks below into the correct order to declare the variables and then print the following story. One day Jay went shopping. He wanted to buy shoes. But, he didn’t like any. So, Jay went home.
Write the code below to calculate and print how many blocks you can travel in an hour if you walk .3 blocks every minute. It should print: “I will travel 18 blocks in an hour if I walk .3 blocks every minute.”
Name each of the values. Calculate the
totalBlocks it will take and print the information.
Discuss topics in this section with classmates.