Question: Goal: Build user - friendly error messages on exceptions. Assignment: Three variables, price, tax and discount, supposedly hold strings of digits, suitable for converting to

Goal: Build user-friendly error messages on exceptions.
Assignment: Three variables, price, tax and discount, supposedly hold strings of digits, suitable for converting to floats. Write code that converts them and displays the total cost (price *(1+ tax)- discount), rounded to the second decimal digit. However, if any variable fails to convert, display a string "Failed to convert value(s): " followed by the names of the variable(s) that failed, separated by space. The variables should be sorted as price, tax and discount.
If in order the variables were "Hi","0.09","1:99", the output would be Failed to convert value(s): price discount.
python

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!