Shopping Calculator using Python
Hello, welcome to CodingFizz,
In this tutorial, we will learn how to make a simple shopping calculator which is used to calculate the sum of the amount that you have bought from a shop with the item name.
Here, We will use a while loop which will be run infinitely, and an if-else statement.
Otherwise, it seems like a simple arithmetic Calculator. You can easily make it as well as modify it.
Source Code:
sum=0
while(True):
print("\nIf you want to exit then press double 'Enter'")
item=input("\nItem: ")
price=input("\nAmount: ")
if(item!=""):
if(price!=""):
sum=sum+int(price)
else:
print("\nTotal Amount: ",sum)
break
Output:
If you want to exit then press double 'Enter'
Item: eggs
Amount: 40
If you want to exit then press double 'Enter'
Item: bread
Amount: 26
If you want to exit then press double 'Enter'
Item: chocolate
Amount: 75
If you want to exit then press double 'Enter'
Item:
Amount:
Total Amount: 141
0 Comments