Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have written a code for this but I cannot get the money_spent to be multiplied by this discount def coupon(money_spent): Return coupon based

image text in transcribedI have written a code for this but I cannot get the money_spent to be multiplied by this discount

def coupon(money_spent): """ Return coupon based on amount spent coupon == =10 but 60 but 150 but 210 there is a 14 percent coupon used """ if money_spent >10: return (money_spent) elif money_spent >=10 and money_spent 60 and money_spent 150 and money_spent 210: return (money_spent*0.14)

print(coupon(9)) print(coupon(30)) print(coupon(90)) print(coupon(180)) print(coupon(240))

Please solve my problem for me

Exercise 2 (Based on an exercise by Cay Horstmann and Rance Necaise) A supermarket awards coupons depending on how much a customer spends on groceries. For example, if you spend $50, you'll get a coupon worth 8% of that amount ( $4). The following table shows the percentage used to calculate the coupon awarded for different amounts spent: Use the function design recipe (examples, header, description, body, test) to develop a function named coupon. The function has one parameter, which is the amount spent on groceries. Use a descriptive name. The function returns the value of the coupon. Your function definition must have type annotations and a complete docstring (a brief description of what the function does, any preconditions, and two or three examples showing how to use the shell to test the functions). Type the function definition below the comment, \# Exercise 2. Use the Python shell to test coupon

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

3. Develop a case study.

Answered: 1 week ago