I keep getting minor errors I can't figure out and I don't knowhow to convert decimal .10 to percentage 10%either. Â
With these functions defined now expand the program for a companywho gives discounts on items bought in bulk.
Create a main function and inside of it ask the user how manydifferent items they are buying.
For each item have the user input a price and quantity, validatingthem with the functions that you wrote.
Use your discount function to find the discount for each item'squantity and calculate the discounted price.
Print the discounted price in $9,999.99 format
Sum the discounted totals for all items and display this grandtotal at the end.
Print the percentages in 99.9% format.
In addition to summing the discounted totals, also sum theun-discounted totals.
At the end display both of these values and then calculate andprint the overall percentage saved in 99.9% format.
def discount ():
discount = 0.00
if quantity >= 0 and quantity <= 19 :
discount = 0.00
if quantity >= 20 and quantity >= 49 :
discount = 0.05
if quantity >= 50 and quantity <= 99 :
discount = 0.08
if quantity >= 100 :
discount = 0.10
return discount
# user input quantity
def quantity ():
quantity = 0
quantity = int (input ('What is the quantity? '))
while quantity < 1 or quantity > 2000 :
print ('Error, Please enter a quantity between 1 and 2000.')
quantity = int (input ('What is the quantity? '))
return quantity
# user input price
def price ():
price = 0.0
price = float (input ('What is the price? '))
while price < 0.0 :
print ('Error, the price must be greater than $0.00')
price = float (input ('What is the price? '))
return price
# main
def main ():
for i in range (items) Â Â
items = int (input ('How many different items are you purchasing?'))
quantity ()
discount ()
price ()
Total_price = sum (price)
Total_discount = sum (discount)
Discounted_price = price - (price * discount)
Total_Discounted_price = Total_price - (Total_price *Total_discount)
print ('For item ',i +1,,' ' Discounted_price, ' with a ',discount, format (.2f, sep=''))
print ('Total order is ', Total_Discounted_price, ' with a ',Total_discount, format (.2f, sep=''))
#initiate
main ()