Food Order
Python Exercises
🍽️ Python Mini Project: Online Restaurant Order App
In this activity, you’ll create a
restaurant ordering system that shows menus,
calculates totals, and simulates food preparation! 🧑🍳
🧩 Step-by-Step Instructions:
-
Import the
timemodule
This will help you create a delay when the food is being “prepared”.import time -
Create a menu dictionary with items and prices
This makes your menu easy to manage.menu = {
"1": ("Burger", 30000),
"2": ("Pizza", 45000),
"3": ("Pasta", 40000)
} -
Display the menu to the user
Show each food and its price with numbers to choose from.print("🍔 Welcome to Python Restaurant!")
for key, item in menu.items():
print(f"{key}. {item[0]} — Rp{item[1]}") -
Ask the user to select an item
Use number input (1, 2, or 3).choice = input("Select your menu number: ")
food, price = menu[choice] -
Ask for quantity
Multiply by price to get total cost.qty = int(input("Enter quantity: "))
total = price * qty -
Ask for extras (drinks or desserts)
Show options and add to the total if chosen.extra_choice = input("Would you like a drink or cake? (yes/no): ")
if extra_choice.lower() == "yes":
total += 10000
print("Added drink or cake Rp10000")
-
Ask for customer’s name
name = input("Enter your name: ")
-
Show total amount and ask for payment
print(f"Total to pay: Rp{total}")
paid = int(input("Enter amount paid: "))
if paid >= total:
print("✅ Payment accepted!") -
Show “Preparing Order” with a 1-minute timer
Usetime.sleep()to simulate waiting.print("⏳ Preparing your order...")
for i in range(5):
print(f"Ready in {i} seconds")
time.sleep(1) -
After timer, show “Order Ready!” and
“Delivering...”
print(f"🍱 {name}, your order is ready!")
print("🚗 Delivering your order...") time.sleep(3)
-
Ask for delivery verification
Confirm that the order is received.done = input("Did you receive your order? (yes/no): ")
if done.lower() == "yes":
print("🎉 Thank you for ordering from Python Restaurant!")
💪 Extra Challenge:
import
time
def foodOrder():
menu = {
"1": ("Burger", 30000),
"2": ("Pizza", 45000),
"3": ("Pasta", 40000)
}
print("🍔 Welcome to Python Restaurant!")
for key, item in menu.items():
print(f"{key}. {item[0]} — Rp{item[1]}")
choice = input("Select your menu number: ")
food, price = menu[choice]
qty = int(input("Enter quantity: "))
total = price * qty
extra_choice = input("Would you like a drink or cake? (yes/no): ")
if extra_choice.lower() == "yes":
total += 10000
print("Added drink or cake Rp10000")
name = input("Enter your name: ")
print(f"Total to pay: Rp{total}")
paid = int(input("Enter amount paid: "))
if paid >= total:
print("✅ Payment accepted!")
else:
print(f"❌ Rp{total-paid} remaining. Please pay the balance.")
remaining = int(input("Enter paid remaining amount: "))
if paid + remaining >= total:
print("✅ Payment accepted!")
print("⏳ Preparing your order...")
for i in range(10, 1, -1):
print(f"Ready in {i} seconds")
time.sleep(1)
print(f"🍱 {name}, your order is ready!")
print("🚗 Delivering your order...")
time.sleep(3)
done = input("Did you receive your order? (yes/no): ")
if done.lower() == "yes":
print("🎉 Thank you for ordering from Python Restaurant!")
# Start ordering
foodOrder()
def foodOrder():
menu = {
"1": ("Burger", 30000),
"2": ("Pizza", 45000),
"3": ("Pasta", 40000)
}
print("🍔 Welcome to Python Restaurant!")
for key, item in menu.items():
print(f"{key}. {item[0]} — Rp{item[1]}")
choice = input("Select your menu number: ")
food, price = menu[choice]
qty = int(input("Enter quantity: "))
total = price * qty
extra_choice = input("Would you like a drink or cake? (yes/no): ")
if extra_choice.lower() == "yes":
total += 10000
print("Added drink or cake Rp10000")
name = input("Enter your name: ")
print(f"Total to pay: Rp{total}")
paid = int(input("Enter amount paid: "))
if paid >= total:
print("✅ Payment accepted!")
else:
print(f"❌ Rp{total-paid} remaining. Please pay the balance.")
remaining = int(input("Enter paid remaining amount: "))
if paid + remaining >= total:
print("✅ Payment accepted!")
print("⏳ Preparing your order...")
for i in range(10, 1, -1):
print(f"Ready in {i} seconds")
time.sleep(1)
print(f"🍱 {name}, your order is ready!")
print("🚗 Delivering your order...")
time.sleep(3)
done = input("Did you receive your order? (yes/no): ")
if done.lower() == "yes":
print("🎉 Thank you for ordering from Python Restaurant!")
# Start ordering
foodOrder()