In this PA, you will be writing two simple programs that print out text. Note that this programming assignment (PA) is relatively straightforward. Not all of the future PAs will be this way. It is simple because we have not yet covered a wide variety of programming concepts, so there’s only so much I can reasonably expect you to be able to program. The PAs will get more challenging, but also, hopefully, more interesting!
Remember - a part of this PA is filling out the 110 student survey. Don’t forget to fill this out … it is worth points!
This should not take more than 15 minutes. Please fill it out thoroughly, accurately, and honestly.
Mad Libs is a simple game / activity where the host player prompts other participant(s) for words of various types. For instance, the host might ask the other participants for various words that fall into categories such as nouns, places, names, verbs, etc. These words are filled in to blanks in a story, and after the host has gotten all of the words filled in, the story is read aloud. For instance, here is a printable mad lib from madlibs.com.
In this programming exercise, you’ll write two mad lib program, that act as the host of the game. The program will prompt the participant (the computer user) for various words, and then it will print out a story using these words.
The first program should be named move.py
.
The outline of the story is shown below:
??? decided to move from her apartment on 5th
to a condo on ???. She called her friend ???
for help. However, they could not fit ??? into
the moving truck, so they had to rent a ??? ???
in order to move it!
The locations with ???
indicate that these should be replaced with a word specified by the computer user.
You should prompt the user for 6 inputs, and fill them in to the story.
An example of running the program would look like so:
A female name:
Janet
A street name:
Loopdydoo Avenue
A male name:
Richard
An object:
Christmas tree
A vehicle:
Horse-drawn carriage
An adjective:
Off-road
----------
Janet decided to move from her apartment on 5th
to a condo on Loopdydoo Avenue. She called her friend Richard
for help. However, they could not fit Christmas tree into
the moving truck, so they had to rent a Off-road Horse-drawn carriage
in order to move it!
The second program should be named mathematics.py
.
The outline of the story is shown below:
??? entered the classroom and began to give a lecture.
"Give me some numbers for variables A and B!" ??? shouted.
"???" ??? replied.
Immediately after, ??? followed up with "???"
??? then replied: "Great, now plug those into the pythagorean theorem. What is C?"
There were a few moments of silence, then ??? said:
"????"
"Correct. Now, what is the area of a rectangle with A and B and the length of the sides?"
"???!" ??? exclaimed.
"Good. Class dismissed."
Again, locations with ???
indicate that these should be replaced with a word specified by the computer user, or a number that is calculated based on the user inputs.
You should prompt the user for 5 inputs.
Two of these you should treat as numbers, and you should do some calculations with these.
Name of teacher:
Joe
A female student:
Sally
A male student:
Bob
A whole number:
10
Another whole number:
20
----------
Joe entered the classroom and began to give a lecture.
"Give me some numbers for variables A and B!" Joe shouted.
"10" Sally replied.
Immediately after, Bob followed up with "20"
Joe then replied: "Great, now plug those into the pythagorean theorem. What is C?"
There were a few moments of silence, then Sally said:
"22.36?"
"Correct. Now, what is the area of a rectangle with A and B and the length of the sides?"
"200!" Bob exclaimed.
"Good. Class dismissed."
In this program, you will print out ascii art of the white house (pictures above).
Name your progam white_house.py
.
Your program should ask the user for three numbers: the width of the sides, the width of the middle, and the flag height.
The side width will increase the width of the left and right sides in accordance with the number provided.
The middle with will control the width of the middle section of the white house.
The flag height will control the height of the flag pole.
Below is a diagram showing what component of the house each input value determines.
The house shown in the image has a side with of 4, a middle width of 2, and a flag height of 3. When the width of the sides increase, it actually increases by more than one character. It actually increases by 3 characters on each side, following the pattern of windows and wall. Similarly for the middle. The width increases by 4 characters on each side of the center of the building. See the image below for reference.
Also, the height of the white house should be a function of the two width inputs. The formula to determine the height is:
Use that calculation to determine how many rows tall the house should be!
Below are just a few examples of this program running with different input values provided. You will be able to use the differ and/or gradescope to test for correct output.
Specify side width:
1
Specify middle width:
1
Specify flag height:
1
|##
|
.-.-''-.-.
;.__--__.;
.___[--------]___.
|II ||IIHHII|| II|
|.. ||..||..|| ..|
Don’t forget to include a header/file comment in your code! Include your name and a description of what the program does. For instance:
###
### Author: Your Name Here
### Class: CSc 110
### Description: Describe your program with one
### or more sentences of text.
###
You should also do your best follow the code Style Guidelines
This PA is due June 12th, 2023 by 7pm. Turn in the three python programs via Gradescope. You should try to make sure that all of the test cases pass. If you don’t you will likely lose points. You can still submit without all of the cases passing, though that is not preferable.