Python Lab Assesment 23BCS80318
Python Lab Assesment 23BCS80318
Lab assesment
Student Name: Steven Lucas UID:23BCS80318
Branch:CSE Section/Group:608 B
Semester:3rd Date of Performance:22/10/2024
Subject Name:Python Subject Code:23CSP 201
1. Aim:
Restaurant management.
Concept:
A food chain manages orders access 50 restaurants location.
Problem:
-order processing
-ingredient inventory
-menu management
Tasks:
Use sets for active orders.
Implement quick sort for order priority
2. Requirements(Hardware/Software):
Online compiler
3. Procedure:
Code.
active_orders = []
ingredient_inventory = {
'restaurant_1': {'tomatoes': 50, 'cheese': 30, 'flour': 20},
'restaurant_2': {'tomatoes': 60, 'cheese': 20, 'flour': 15},
}
menu = {
'restaurant_1': {'pizza': {'ingredients': {'flour': 2, 'cheese': 1, 'tomatoes':
2}, 'price': 15.99}},
'restaurant_2': {'pasta': {'ingredients': {'flour': 1, 'cheese': 1,
'tomatoes': 1}, 'price': 12.99}}
}
def quicksort(orders):
if len(orders) <= 1:
return orders
pivot = orders[len(orders) // 2]
left = [x for x in orders if x['time'] < pivot['time']]
middle = [x for x in orders if x['time'] == pivot['time']]
right = [x for x in orders if x['time'] > pivot['time']]
return quicksort(left) + middle + quicksort(right)
for _ in range(num_orders):
order_item = input("Enter the item you'd like to order: ")
time = float(input("Enter the time of order (e.g., 12.30 for 12:30 PM):
"))
place_order(restaurant, order_item, time)
sorted_orders = quicksort(active_orders)
print("Sorted Orders by Time of Placement:", sorted_orders)
4. Output:
5. Learning Outcome:
-Understand how to manage inventory and orders using sets and dictionaries in
Python.
-Learn to implement QuickSort to sort data based on custom criteria (e.g., time).