-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7. Q 5.py
More file actions
30 lines (26 loc) · 850 Bytes
/
7. Q 5.py
File metadata and controls
30 lines (26 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Create two dictionaries – one containing grocery items
#and their prices and another containing grocery items and quantity purchased.
#By using the values from these two dictionaries compute the total bill.
# Dictionary of item prices
prices = {
'rice': 50,
'milk': 30,
'bread': 20,
'eggs': 6
}
# Dictionary of quantities purchased
quantities = {
'rice': 2, # 2 kg
'milk': 3, # 3 liters
'bread': 1, # 1 loaf
'eggs': 12 # 12 eggs
}
# Calculate the total bill
total_bill = 0
print("Item-wise Bill:\n")
for item in prices:
if item in quantities:
item_total = prices[item] * quantities[item]
total_bill += item_total
print(f"{item.capitalize()}: {quantities[item]} × {prices[item]} = ₹{item_total}")
print("\nTotal Bill: ₹", total_bill)