BYU logo Computer Science

To start this assignment, download this zip file.

Homework 3a — Interactive Programs

For all interactive programs, be sure to include a space at the end of the string you give to input().

For example:

name = input('What is your name? ')

Notice the space between the question mark and the quotation mark.

Be sure you can pass the tests before you turn in the assignment. Review the guide on using pytest if you need to review using pytest and what to do if a test fails.

1. Pizza time

For this problem, write a program that takes a pizza order. The program input and output should look like this:

Welcome to Papa John's!
What is your name? <person enters name>
What kind of pizza do you want? <person enters kind of pizza>
What toppings do you want? <person enters toppings>
<name> wants a <kind> pizza with <toppings>!

The starter code is in pizza_time.py.

There are tests in test_pizza_time.py.

2. Mad libs (short)

Write a mad libs that has input and output like this:

Welcome to Mad Libs!
Please enter the following words:
Noun: <person enters a noun>
Adjective: <person enters an adjective>
Noun: <person enters a noun
Character: <person enters a character>
Animal (Plural): <person enters an animal>
<noun1> sat on a <noun2>. <noun1> had a <adjective> fall. All <character>'s <animal> and all the <character>'s men couldn't put <noun1> together again.

The starter code is in mad_libs_short.py.

There is a test in test_mad_libs.py — use the short test.

3. Mad libs (long)

Write a mad libs that has input and output like this:

Welcome to Mad Libs!
Please enter the following words:
Noun: <person enters noun>
Adjective: <person enters adjective>
Adjective: <person enters adjective>
Noun: <person enters noun>
Number: <person enters number>
Adjective: <person enters adjective>
Past-Tense Verb: <person enters verb>
Game: <person enters game>
Verb: <person enters verb>
Once upon a time a student at found themselves in a <noun1> class. The teacher was so <adjective> that the student started to daydream about a <noun2>. Then the student woke up and realized that they were still in class. The teacher was so <adjective2> that they gave the student a <number> on the assignment. The student was so <adjective3> that he <past-tense-verb> the class and went home to play <game>. The moral of the story is that you should never <verb2> in class.

The starter code is in mad_libs.py.

There is a test in test_mad_libs.py.

4. Write your own

Write your own interactive program in the file called write_your_own.py. Your program should:

  • Use input() exactly three times (EOF or EOFError means you called input() too many times)
  • Use print() at least three times
  • Use formatted strings

Tests

Be sure you can pass the tests before you turn in the assignment. Review the guide on using pytest if you need to review using pytest and what to do if a test fails.

Grading

ActivityPoints
Pizza Time5
Mad Libs (short)5
Mad Libs (long)5
Write your own5 (manually graded)

Manual grading will focus on decomposition and use input, print, and formatted strings.