Total Expenses Program in Python


While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 10. If quantity and price per item are input through the keyboard, write a program to calculate the total expenses.

This program is written in the Python programming language and it is designed to calculate the total expenses of purchasing a certain quantity of items, based on the quantity purchased and the amount per item.

  • It starts by using the "input()" function to accept two values from the user, the quantity purchased and the amount per item, which are stored in variables named "qty" and "amt" respectively.
  • The program then uses an if-else statement to check if the quantity purchased is greater than 10. If the condition is true, then the program multiplies the quantity by the amount per item to find the total expenses and then subtracts 10% of the total expenses to give the final total expenses.
  • If the condition is false, the program simply multiplies the quantity by the amount per item to find the total expenses. Finally, the program uses the "print()" function to display the total expenses.

Source Code

qty = int(input("Enter the Quantity Purchased :"))
amt = float(input("Enter the Amount Per Item :"))
if(qty>10):
	total = qty * amt; 
	total = total- (total * 0.1)
else:
	total = qty * amt
 
print("Total Expenses is :",total)

Output

Enter the Quantity Purchased :14
Enter the Amount Per Item :78
Total Expenses is : 982.8


Example Programs