Using Python, students will use variables, input, and printing to create a Mad Lib.
The program will print out the title of the Mad Libs story, as well as a short explanation of game play:
The program should then prompt the user to enter in nouns, verbs, adjectives, proper nouns, and adverbs:
Enter a proper noun:
Enter a place:
Enter another place:
Enter an adverb:
Enter a noun:
Enter an adjective:
Enter an adverb:
Enter a verb:
Enter a place:
Enter an adjective:
As mentioned above the program must request words from the user. The following can be included in the program:
10 different words inputted
Variable names should correspond to the part of speech requested and part of the story they belong to (e.g. noun1, verb2, etc)
You may only use 3 print statements to tell your story
Dear Learner,
Here is the solution code
def MadLibsStory(): #function definition
print("Enter a proper noun:")
properNoun = input() #asking for properNoun
print("Enter a place:")
place1 = input()#taking first place input
print("Enter another place:")
place2 = input()#taking second place input (notice the
name of the variable)
print("Enter an adverb:")
adverb = input()#taking input for adverb
print("Enter a noun:")
noun = input()#asking for a noun
print("Enter an adjective:")
adjective = input()#taking input for an
adjective
print("Enter an adverb:")
adverb2 = input() #taking second adverb
print("Enter a verb:")
verb = input()# asking for a verb
print("Enter a place:")
place3 = input()# asking for a third place
print("Enter an adjective:")
adjective2 = input() #taking second adjective
print("During the war of 2427, "+adjective+"
countries like "+place1+" were trying to attack "+place2+".")
#print statement 1
print("But the "+adjective2+" king "+properNoun+",
with his "+noun+" protected his country very "+adverb+".") #print
statement 2
print("Then his brother came from "+place3+" and
"+verb+" him "+adverb2+".") # print statement 3
print("Welcome to Mad Libs Story")
print("Enter the requested words to generate a story")
MadLibsStory() #function call
SCREENSHOT OF THE CODE:
SAMPLE OUTPUT:-
I hope I have answered the question the way you were expecting. If you still have any doubts or want any further explanation, feel free to ask us in the comment section.
Please leave a like if this was helpful.
Thanks,
Happy Studying.
Get Answers For Free
Most questions answered within 1 hours.