Nov-02-2020, 11:36 PM
Hello, sorry if this isn't explained well or I'm doing something wrong, I am extremely new to python coding and I need help with an assignment in my coding class. We are making a program that calculates a discount depending on the amount of packages you purchased. Here is the prompt and my code, along with the error I keep receiving.
THE PROMPT
A software company sells a package that retails for $99. Quantity discounts are given according to the following table:
Quantity Discount
10-19 20%
20-49 30%
50-99 40%
100 or more 50%
Design a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.
MY CODE
quantity=int(input("Please enter the amount of packages you purchased."))
if quantity >= "100":
discount = 50
else:
if quantity >= "50":
discount = 40
else:
if quantity >= "20":
discount = 30
else:
if quantity >= "10":
discount = 20
else:
discount = 0
print('Your discount is' & discount & ' percent off.')
totaldiscount = discount / 100
discountprice = totaldiscount * 99
finalprice = 99 - discountprice
print("The total amount of the purchase after the discount is $" & finalprice)
THE ERROR MESSAGE
TypeError: '>=' not supported between instances of 'int' and 'str'
>>>
Thank you so much for helping me out, I really appreciate it
THE PROMPT
A software company sells a package that retails for $99. Quantity discounts are given according to the following table:
Quantity Discount
10-19 20%
20-49 30%
50-99 40%
100 or more 50%
Design a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.
MY CODE
quantity=int(input("Please enter the amount of packages you purchased."))
if quantity >= "100":
discount = 50
else:
if quantity >= "50":
discount = 40
else:
if quantity >= "20":
discount = 30
else:
if quantity >= "10":
discount = 20
else:
discount = 0
print('Your discount is' & discount & ' percent off.')
totaldiscount = discount / 100
discountprice = totaldiscount * 99
finalprice = 99 - discountprice
print("The total amount of the purchase after the discount is $" & finalprice)
THE ERROR MESSAGE
TypeError: '>=' not supported between instances of 'int' and 'str'
>>>
Thank you so much for helping me out, I really appreciate it