Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USE PYTHON! Write a function calculate_bill (cart, coupon) that takes in a list of floats representing item prices (cart), as well as a coupon float
USE PYTHON!
Write a function calculate_bill (cart, coupon) that takes in a list of floats representing item prices (cart), as well as a coupon float value (coupon). This function should compute the sum of the item prices inside cart and deduct the flat coupon amount. Then, the program should apply a 8.7% sales tax to get the final bill amount, which you should return as a float. The returned total price should never be negative. Prices in cart will always be positive and will always contain at least one item. For example: calculate_bill([5.60, 4.75, 3.00], 2.00)) should return 12.33745 calculate bill([5.60, 4.75], 2.00)) should return 9.07645 (Don't worry about rounding the float.) Then, write a function assess_purchase (shopping_cart, coupon, budget) that takes in a shopping cart list of item prices, a coupon float value, and a budget float value. This function should consider the cart list items in exactly the order they're given in the shopping_cart and figure out the maximum number of items that can be purchased without exceeding the budget amount. Your assess_purchase () function should call calculate_bill(). For example, assuming these inputs: = my_cart [5.60, 4.75, 3.00) my_coupon = 2.00 my_budget = 12.00 assess_purchase (my_cart, my_coupon, my_budget) should return 2 This is because only the first two items in the cart can be purchased without exceeding the 12.00 budget. If we bump my_budget up to 13.00, then calling assess_purchase () should output 3 because the cost of all three items would be within the new budgetStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started