Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 4 (5 points): Purpose: To practice console input and output of strings. Degree of Difficulty: Easy A 'mad-lib' is a fill-in-the blank game. One

image text in transcribed
Question 4 (5 points): Purpose: To practice console input and output of strings. Degree of Difficulty: Easy A 'mad-lib' is a fill-in-the blank game. One player writes a short story in which some words are re- placed by blanks. For each word that is removed, the appropriate part of speech is noted: eg. noun (person/place/thing), adjective (word that describes a noun), verb (an action, eg eat), adverb (modi- fies a verb, eg. 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 textbook Section 242 "Reading Strings from the Keyboard") 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 isimportant! 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 program's 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 user's data gets put in the story. If you're using PyCharm to run your program, the user input will also be green, but it won't show any blue text Enter a verb ending in "ing": zipping squirtle Enter a verb (past tense): zapped Pikachu was zipping through some tall grass. Suddenly, a squirtle appeared! The squirtle zapped Pikachu. It vas not very effective. Enter a noun: What to Hand In Hand in your solution in a file called alg4.py- 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 instructor's name)

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

Students also viewed these Databases questions