Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To practice console input and output of strings. A mad - lib is a fill - in - the blank game. One player writes a

To practice console input and output of strings.
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:
(a) 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.
(b) 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.
You must write your own unique story. There is no good reason why two students should submit the same
story. Remember you must use a minimum of three blanks, and therefore, your program must read at
least three words from the console. You can have more blanks, but get all your other work done before
you spend a lot of time having fun with this question!
Sample Run
Here is an example of how your programs console output might look. Do not submit this story! Write your
own story. In our example, we use green text to show what the user typed in; blue text highlights where
the users data gets put in the story. If youre using PyCharm to run your program, the user input will also
be green, but it wont show any blue text.
Enter a verb ending in " ing ": zipping
Enter a noun : squirtle
Enter a verb ( past tense ): zapped
Pikachu was zipping through some tall grass .
Suddenly , a squirtle appeared !
The squirtle zapped Pikachu .
It was not very effective .
What to Hand In
A file called a1q2.py containing your finished program, as described above.
Evaluation
2 marks for reading text from the console;
2 marks for printing the story to the console in an aesthetically pleasing manner;
1 mark for choosing appropriate variable names (variable names should be descriptive of the data
referred to by the variable; single-letters and abbreviations should be avoided).
-1 mark if identifying information is missing (name, NSID, student number and instructors name).
Page 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions

Question

=+5. What is your impression of the Carbon Principles?

Answered: 1 week ago