QUESTION IMAGE
Question
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 a program that reads four values from input and stores the values in variables first_name, generic_location, whole_number, and plural_noun. the program then uses the input values to output a short story. the first input statement is provided in the code as an example. notes: to test your program in the develop mode, pre - enter four values (in separate lines) in the input box and click the run program button. the auto - grader in the submit mode will test your program with different sets of input values. ex. if the input values are eric chipotle 12 cars then the program uses the input values and outputs a story eric went to chipotle to buy 12 different types of cars ex. if the input values are brenda philadelphia 6 bells then the program uses the input values and outputs a story brenda went to philadelphia to buy 6 different types of bells main.py 1 # read a value from a user and store the value in first_name 2 first_name = input(enter your name: ) 3 # 4 # todo: type your code to read three more values here. be sure to use the correct variable names! 5 6 7 # output a short story using the four input values. do not modify the code below. 8 print(, went to, generic_location, to buy, whole_number, different types of, plural_noun)
To solve this problem, we need to complete the Python program to read four input values (first name, generic location, whole number, and plural noun) and then use these values to output a short story. Here's the step-by-step breakdown:
Step 1: Read the generic location
We need to read the generic location from the user. We'll use the input() function and store the value in the variable generic_location.
generic_location = input('Enter a generic location: ')
Step 2: Read the whole number
Next, we read the whole number from the user. Since we need to use it as a number in the output, we'll convert the input (which is a string) to an integer using the int() function and store it in the variable whole_number.
whole_number = int(input('Enter a whole number: '))
Step 3: Read the plural noun
Finally, we read the plural noun from the user and store it in the variable plural_noun.
plural_noun = input('Enter a plural noun: ')
Complete Program
Putting it all together, the complete main.py file will be:
# Read a value from a user and store the value in first_name
first_name = input('Enter your name: ')
# Read a generic location
generic_location = input('Enter a generic location: ')
# Read a whole number
whole_number = int(input('Enter a whole number: '))
# Read a plural noun
plural_noun = input('Enter a plural noun: ')
# Output a short story using the four input values. Do not modify the code below.
print(first_name, 'went to', generic_location, 'to buy', whole_number, 'different types of', plural_noun)of Output
When you run this program, it will prompt the user for four inputs:
- First name (e.g., "Eric")
- Generic location (e.g., "Chipotle")
- Whole number (e.g., 12)
- Plural noun (e.g., "cars")
The program then uses these inputs to construct and print a sentence in the format: [first_name] went to [generic_location] to buy [whole_number] different types of [plural_noun].
For example, if the inputs are "Eric", "Chipotle", 12, and "cars", the output will be:
Eric went to Chipotle to buy 12 different types of cars
This program correctly reads the required inputs and uses them to generate the desired short story output.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
of Output
When you run this program, it will prompt the user for four inputs:
- First name (e.g., "Eric")
- Generic location (e.g., "Chipotle")
- Whole number (e.g., 12)
- Plural noun (e.g., "cars")
The program then uses these inputs to construct and print a sentence in the format: [first_name] went to [generic_location] to buy [whole_number] different types of [plural_noun].
For example, if the inputs are "Eric", "Chipotle", 12, and "cars", the output will be:
Eric went to Chipotle to buy 12 different types of cars
This program correctly reads the required inputs and uses them to generate the desired short story output.