Beginner Codes/Python/Concession Stand Program
32%

Instructions

Syntax

price = menu[item] total += price

Concession Stand Program 🍿

Movie theater-la interval appo snacks vaanguradhukku oru edam irukkum la? Adhu dhaan Concession Stand!

Idhula namba rendu concept-a onna serkka porom:

  1. Dictionary: Menu-oda items and prices-a store panna.
  2. List: User vaangura items-a cart-la add panna.

1. Menu and Cart Setup 🛒

Mudhalla oru Menu-um, empty Cart-um create pannuvom:

menu = {"Pizza": 200, "Popcorn": 150, "Soda": 50}
cart = ["Pizza", "Soda"] # User vaanguna items

2. Checking Out 💸

Ippo user cart-la ulla items-ku total price kandupudikkanum. for loop vechu ovvoru item-a eduthu, menu dictionary-la adhoda vilaiya thedi total-la add pannanum!

total = 0
for item in cart:
    price = menu[item] # Dictionary-la irundhu vilaiya edukkurom
    total += price
print(f"Total: Rs.{total}")

Interactive Concession Stand 🍿

Kizhe ulla stand-la snacks-a click panni cart-la add pannunga. Apram Start Loop click panni, Python eppadi dictionary-la price-a thedudhu nu paarunga!

Concession Stand Program

menu = {
"pizza": 200,
"popcorn": 150,
"soda": 50,
"candy": 30
}
cart = [empty]
total = 0
for item in cart:
price = menu[item]
total += price
Click items to add them to your cart. Notice how we only store the item name (Key), not the price!

Menu

Your Cart0 items

Cart is empty

Your Turn! (Unga neram!)

Kizhe ulla editor-la code-a complete pannunga.

  1. for item in cart: loop ulla, menu dictionary-la irundhu andha item-oda price-a eduthu total kooda add pannunga.

Help

Concession Stand ProgramExercise 26/7735 XP
❴❵ script.py
python.code
python
Loading...
Terminal
Terminal — python
Beginner Codes Terminal v1.0.0
─────────────────────────────────────
Ready. Click "Run Code" to execute...
Ready
Piston APIPYTHON0 lines