0% found this document useful (0 votes)
23 views5 pages

Python Lab Assesment 23BCS80318

Uploaded by

mandemalan212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views5 pages

Python Lab Assesment 23BCS80318

Uploaded by

mandemalan212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

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 check_inventory(restaurant, order_item):


if order_item not in menu[restaurant]:
return False
for ingredient, quantity in
menu[restaurant][order_item]['ingredients'].items():
if ingredient_inventory[restaurant].get(ingredient, 0) < quantity:
return False
return True

def update_inventory(restaurant, order_item):


for ingredient, quantity in
menu[restaurant][order_item]['ingredients'].items():
ingredient_inventory[restaurant][ingredient] -= quantity

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)

def place_order(restaurant, order_item, time):


if check_inventory(restaurant, order_item):
order_id = len(active_orders) + 1
active_orders.append({'id': order_id, 'item': order_item, 'time':
time})
update_inventory(restaurant, order_item)
print(f"Order placed! Order ID: {order_id}")
else:
print("Sorry, we can't place your order right now due to insufficient
ingredients.")

restaurant = input("Enter restaurant (restaurant_1 or restaurant_2): ")


num_orders = int(input("Enter the number of orders you want to place:
"))

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).

-Gain experience in handling user inputs for dynamic program execution.


- Develop skills in combining real-world problems with algorithmic sorting for
efficient data management.

You might also like