Project Level 2: Intermediate
This project is designed for intermediate learners who know Python fundamentals and are practicing building complete programs.
Project Description
Create a command line program that simulates a basic billing system for a supermarket. The user can input items purchased (e.g., butter, eggs, etc), their prices, and quantities. The app will calculate the total bill, apply any applicable discounts, and display an itemized bill summary. This project focuses on loops, dictionaries, and arithmetic calculations.
Learning Benefits
You will practice working with loops, dictionaries, and arithmetic calculations while simulating a real-world application. This project helps improve your problem-solving skills and teaches you how to handle user input and display formatted output.
Prerequisites
Required Libraries: No libraries are needed for this project.
Required Files: No files are needed for this project.
IDE: You can use any IDE on your computer to code the project.
Danger Zone
Once you code the project, compare it with our two solutions given in the button below.
def calcbilling(new_dict):
#print(new_dict)
print("---BIll Summary----")
subtotal = 0
for key,value in new_dict.items():
tot = value[0] * value[1]
print(f"{key}: {value[0]} X ${value[1]} = ${tot}")
subtotal += tot
print(f"Subtotal: ${subtotal}")
print(f"Sales Tax 5%: $0.53")
total = subtotal + 0.53
print(f"Total: {total}")
print("Thank you for Shopping with us")
if __name__ == "__main__":
print("Welcome to the Super Market Billing System")
number = int(input("Enter the number of total items: "))
new_dict = {}
for i in range(number):
print(f"Item:{i + 1}")
item_name = input("Enter the Item name: ")
item_quantity = int(input("Enter the Item Quantity: "))
item_price = float(input("Enter the Item Price: "))
new_dict.update({item_name:[item_quantity,item_price]})
#print(new_dict)
calcbilling(new_dict)