Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.9 A2 Madlibs Invitation Dj vu! Another MadLib. This assignment will give you some practice using a dictionary and a list. This assignment is a

image text in transcribed

2.9 A2 Madlibs Invitation Dj vu! Another MadLib. This assignment will give you some practice using a dictionary and a list. This assignment is a bit more challenging. . The MadLib is longer . You can only use two variables - a dictionary containing the substitution values and a list containing the string literals for the text of the story .You may only use a single print statement that references values in the dictionary and list. You may not use any string literals such as Hi' in the print statement. Here's a MadLib invitation form. Dear name1 You are adverb invited! name-is having a-theme-party! It's going to be at a place on day of the week Please make sure you show up at time or else you will be required to _verb a/an _animal with your _body_part Like the previous assignment, you must prompt for each fill-in-the-blank value before printing the entire MadLib with the substitutions. The values should be placed in a dictionary with the fill-in-the-blank as the key. All prompts should include a question mark. Use blanks instead of_s in your prompts (ie.a_place is just 'a place' in the prompt). blanks' fill in the blank - input ('fill in the blank?') Since you cannot use string literals in the print statement, you will need to place them in a list which you can reference in the print statement. To print multiple lines with a single print statement you will need to include'In' in the string literals you put in the list. There should be no extra spaces in the printed MadLib so you will need to append the strings with +in a single expression rather than use, to separate the values in the print statement. madlib = ["Hello", "I "] print (madlib[01 blanks['_fill_in_the_blank_' + madlib[1]) This should give you a pretty good start on the assignment. Remember to declare the variables before you use them. LAB ACTIVITY 2.9.1: A2 Madlibs Invitation 0/10 madliblist.py Load default template ! # Obtain values for each fill-in-the-blank in the MadLib and place them in a dictionary 2 # For 'n' blanks, split the input sentence into at least n+1 parts. Insert spaces and " " wherever needed 3 #eg. Hello-name- 4 Welcome to-place-, 6 # madlib - ["Hello ", in" "Welcome to ", 8# 9# 10 madlib[ 12 # Define a list of strings containing the MadLib text, including blanks, punctuation, and new lines 13 # blanks('name'] - input ("name?) 14 blanks[ 'place input("place?) 15 16 blanks 17 18 # Print the Mad Lib by concatenating values from the list and dictionary 19 print) 20

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

1. Are my sources credible?

Answered: 1 week ago

Question

3. Are my sources accurate?

Answered: 1 week ago

Question

1. Is it a topic you are interested in and know something about?

Answered: 1 week ago