No Negative Args, Please!¶
Download and run the starter code.
What you should see¶
3 items at $2.99 each is:
$8.97
What you should do¶
In the
mainfunction, make theitem_pricea negative number. i.e.,-2.99. Run the program and explain what happens. Answer the following in a comment.What is the error?
What is the message?
On what line does the error occur?
What caused the error?
In the
calc_subtotalfunction, add a check for thequantityvalue. Quantities cannot be negative so also raise aValueErrorif thequantityis negative. In the main function fix theitem_pricevariable to make it positive and make thequantitynegative to observe the error.In the
mainfunction, make bothitem_priceandquantitynegative. What do you see and what do you not see. Explain in a comment.
©2021 Daniel Gallo
This work is licensed under Attribution-NonCommercial-ShareAlike 4.0 International