Python-Lab Assignment 5marks
Python-Lab Assignment 5marks
if 1<= x <=5:
print(fact_1(x))
elif 6<= x <=10:
print(fact_6(x))
elif 11<= x <= 15:
print(fact_11(x))
elif 16<= x <= 20:
print(fact_16(x))
else :
print('Enter number between 1 - 20 ')
output:
#Ques 2
order = {}
with open(order_file, 'r') as o:
for line in o:
dish, quantity = line.strip().split(' : ')
order[dish] = int(quantity)
total = 0
for dish, quantity in order.items():
if dish in menu:
total += menu[dish] * quantity
else:
print(f"{dish} is not in the menu.")
return
output_file = f'bill_{cust_name}.txt'
with open(output_file, 'w') as b:
b.write(f"Customer: {cust_name}\n")
for dish, quantity in order.items():
b.write(f"{dish} x {quantity}: {menu[dish] * quantity}\n")
b.write(f"Total : {total:.2f}\n")
b.write(f"GST (18%) : {gst:.2f}\n")
b.write(f"Tip (5%) : {tip:.2f}\n")
b.write(f"Final Bill: {bill:.2f}\n")
# menu_card.txt
Dabeli : 45
Pizza : 250
Pasta : 100
Namkeen : 50
Sandwich : 35
french_Fries : 65
cold_drink : 40
Ice_Cream : 60
# order.txt
Dabeli : 3
Pizza : 1
Namkeen : 2
cold_drink : 2
Ice_Cream : 1
#outputs:
# Ques 3
# Sorting
my_dict = {'banana': 20, 'apple': 30, 'orange': 10}
sorted_dict_by_value = dict(sorted(my_dict.items(), key=lambda item:
item[1]))