Create Task Practice
Write a simple program to practice for the AP Create Task.
This program will simulate a pizza ordering system. The user can select what size pizza and any number of toppings, and the output is the total price of the pizza.
The basic flow of the program is as follows:
- Ask the user what size pizza they want.
- Allow them to choose any number of toppings.
- Calculate the total price of the pizza.
Don’t forget to disallow invalid inputs.
Use the following values for pizza prices:
| Size | Price |
|---|---|
| Small | $10.99 |
| Medium | $12.99 |
| Large | $14.99 |
Each topping costs $1.50.
Here’s an example of the program being run:
$ python3 pizza.py
Welcome to the Pizza Ordering System!
Available sizes: small, medium, large
What size pizza would you like? small
Available toppings:
1. pepperoni
2. mushrooms
3. onions
4. sausage
5. bacon
6. extra cheese
7. green peppers
8. olives
Enter a topping number (or 'done' to finish): 1
Added pepperoni
Enter a topping number (or 'done' to finish): done
Order Summary:
Size: small
Toppings: pepperoni
Total Price: $12.49
Once you have completed the assignment, write brief answers to the following potential FRQ questions:
-
Identify an unexpected or invalid input that a user could provide to your program. Describe the behavior of your program after it receives this input. If it is not possible for your program to accept an unexpected or invalid input, explain why this is the case.
-
Consider the procedure identified in the Procedure section of your Personalized Project Reference. Identify the parameter(s) used in this procedure. Explain how your identified parameter(s) use abstraction to manage complexity in your program.
-
Consider the list identified in the List section of your Personalized Project Reference. Describe how your program could be written without the use of a list. If it is not possible for your program to work without the use of a list, describe how your program’s functionality would be limited.
-
Consider the first selection statement included in the Procedure section of your Personalized Project Reference. Identify the Boolean expression in this selection statement. Identify a specific value or set of values that will cause this expression to evaluate to false. Explain why the specified value(s) will cause this expression to evaluate to false.
-
Consider the code segment in the List section of your Personalized Project Reference. Suppose another programmer modifies this code segment. Describe a modification the other programmer could make to this code segment that would result in a logic error. Explain why this modification would result in a logic error.
-
Consider the procedure identified in the Procedure section of your Personalized Project Reference. Describe the functionality provided by this procedure. Explain how implementing this functionality as a procedure results in your program being easier to maintain than if the functionality were not implemented as a procedure.
Submit your answers in a Google Doc to the Schoology assignment.