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
main
function, make theitem_price
a 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_subtotal
function, add a check for thequantity
value. Quantities cannot be negative so also raise aValueError
if thequantity
is negative. In the main function fix theitem_price
variable to make it positive and make thequantity
negative to observe the error.In the
main
function, make bothitem_price
andquantity
negative. 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