Create a program in Python (Script Mode) to accept quantity and price per item of a purchased product. Calculate the total amount. Also find out total paid amount after deducting 10% discount on total amount. Display the total amount and total paid amount.
Answers
Answered by
8
qty = int(input("Enter the quantity purchased: "))
price = float(input("Enter the price of the item: "))
print()
ta = qty*price
print("The total amount to be paid: ", str(ta) + ".")
print()
print("You receive a discount of 10%.")
print()
na = ta - (ta*0.10)
print("The total amount to be paid: ", str(na) + ".")
We use int() to accept an integer value since there are calculations to be performed in the succeeding steps.
We use float() to accept decimal values since prices are generally in the form of decimals. If we were to use int() for the price and the user inputs a decimal value, it would result in an error. Hence it is preferable to use float() in such cases.
Similar questions