Assignment 2 – Mad Libs Story
Learning Objective
Write a Python program that creates and uses variables of different types. Get and store input from the user. Output information including escape characters.
Assignment Description
Create your own Mad Libs story. The idea of the Mad Libs game is to write down different words that fit parts of speech, and then incorporate those words into a prewritten story.
Steps
⦁ In PyCharm , open your existing ITP115 project.
⦁ Under the Assignments directory, create a new directory called a2_last_first where last is your last/family name and first is your preferred first name. Use all lowercase letters.
⦁ In the directory, create a new Python file called assignment2.py.
⦁ At the top of the file, put comments in the following format and replace the name, email, and section with your actual information:
# ITP 115, Fall 2022
# Section: number or nickname
# Assignment 2
# Description:
# Describe what this program does such as:
# This program creates a Mad Libs story.
# It gets input from the user and prints output.
⦁ Use the input() function to user input for the following input and store them in variables:
o 5 strings (str)
o 3 integers (int)
o 1 floating point number (float)
This content is protected and may not be shared, uploaded, or distributed.
ITP 115 2022-08-21
o Name the variables whatever you want, but use good coding practice.
o You can get more user input if you want.
o The strings need to be different parts of speech such as a noun, verb, adjective, adverb, or preposition. You can also ask for a special type of the part of speech, such as a place , a proper name , or a color.
⦁ At least two of the values entered must be in used in some mathematical calculation , and the result should be used in the story. Make sure to use the int() and float() functions to convert the strings entered by the user to the appropriate number type.
⦁ Your program must then print out the story with the user’s words injected into the story. You may use multiple print() statements. If you do not use multiple print() statements, then use the new line escape character to print on multiple lines.
⦁ Signify to the user their input in the story using “”. To do this, use escape characters. In other words, when the story is printed, the values of the variables will be surrounded by quotes.
⦁ Since there will quotation marks around the words, follow proper formatting and ensure there are no extra spaces.
10.Create your own story. Do not use the story in the Sample Output.
11.Be sure to comment your code. This means that there should be comments throughout your code. Generally, a comment for every section of code explaining what it does. Points will be deducted for not having comments.
12.Follow coding conventions.
13.Test the program. Look at the Sample Output below. Assignments that do not run are subject to 20% penalty.
14.Prepare your submission:
o Find the a2_last_first folder on your computer and compress it. This cannot be
done within PyCharm.
Last Completed Projects
topic title | academic level | Writer | delivered |
---|