In Python
1.9 LAB: Input: Mad Lib

Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways.

Complete the program to read the needed values from input, that the existing output statement(s) can use to output a short story.

Ex: If the input is:

Eric
Chipotle
12
cars
Then the output is:

Eric went to Chipotle to buy 12 different types of cars

Respuesta :

name = input("Enter a name: ")

place = input("Enter a place: ")

number = input("Enter a number: ")

noun = input("Enter a noun: ")

print("{} went to {} to buy {} different types of {}".format(name, place, number, noun))

I hope this helps!

Following are the Python program for input value and prints its value with the message.

Program Explanation:  

  • In the python code, four variables "na, l, nu, no" are declared that inputs value by using the input method.
  • In this, except for the "nu" variable, all is used for the input string value.
  • After input value, the print method has used that prints value with a message.

Program:

#defining variable that uses the input method to the input value

na = input()#defining na variable to input value

l = input()#defining l variable to input value

nu = int(input())#defining nu variable to input integer value

no = input()#defining no variable to input value

print(na, 'went to', l, 'to buy', str(nu), 'different types of', no)# printing input value and print value with message

Output:

Please find the attached file.

Learn more:

brainly.com/question/18752544

Ver imagen codiepienagoya
ACCESS MORE