A "mad-lib" is a fill-in-the blank game. One player writes a short story in which some words are replaced by blanks. For each word that is removed, the appropriate part of speech is noted: e.g. noun (person/- place/thing), adjective (word that describes a noun), verb (an action, e.g. eat), adverb (modifies a verb, e.g. quickly). Then, before reading the story, the story-writer asks the other player to write down a word of the appropriate part of speech for each blank without knowing the context in which it will be used. In this way, a humorous (sometimes) or non-sensical (usually) story is created. Write your own mad-lib. It must have at least three blanks in it. Now write a Python program that does the following: - Using the input() syntax (see the section "Reading Strings from the Keyboard" from the course read- ings) for reading strings from the console, prompt the user to enter a word of the appropriate part of speech for each blank in your program. Have a different, appropriately named variable refer to each word. - Print your story to the console using the print() syntax, filling in the blanks in your story using the strings referred to by the variables that you gathered in Step 1. While it is possible to do this using a single print(), readability of code is important! You are permitted to use as many print() statements as you wish
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
A "mad-lib" is a fill-in-the blank game. One player writes a short story in which some words are replaced
by blanks. For each word that is removed, the appropriate part of speech is noted: e.g. noun (person/-
place/thing), adjective (word that describes a noun), verb (an action, e.g. eat), adverb (modifies a verb, e.g.
quickly). Then, before reading the story, the story-writer asks the other player to write down a word of the
appropriate part of speech for each blank without knowing the context in which it will be used. In this way,
a humorous (sometimes) or non-sensical (usually) story is created.
Write your own mad-lib. It must have at least three blanks in it. Now write a Python program that does
the following:
- Using the input() syntax (see the section "Reading Strings from the Keyboard" from the course read-
ings) for reading strings from the console, prompt the user to enter a word of the appropriate part of
speech for each blank in your program. Have a different, appropriately named variable refer to each
word.
- Print your story to the console using the print() syntax, filling in the blanks in your story using the
strings referred to by the variables that you gathered in Step 1. While it is possible to do this using a
single print(), readability of code is important! You are permitted to use as many print() statements
as you wish
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images