Python concession stand program 🍿

preview_player
Показать описание
#python #tutorial #course

# Concession stand program

menu = {"pizza": 3.00,
"nachos": 4.50,
"popcorn": 6.00,
"fries": 2.50,
"chips": 1.00,
"pretzel": 3.50,
"soda": 3.00,
"lemonade": 4.25}
cart = []
total = 0

print("--------- MENU ---------")
print(f"{key:10}: ${value:.2f}")
print("------------------------")

while True:
food = input("Select an item (q to quit): ").lower()
if food == "q":
break

print("------ YOUR ORDER ------")
for food in cart:
print(food, end=" ")

print()
print(f"Total is: ${total:.2f}")
Рекомендации по теме
Комментарии
Автор

# Concession stand program

menu = {"pizza": 3.00,
"nachos": 4.50,
"popcorn": 6.00,
"fries": 2.50,
"chips": 1.00,
"pretzel": 3.50,
"soda": 3.00,
"lemonade": 4.25}
cart = []
total = 0

MENU
for key, value in menu.items():
print(f"{key:10}: ${value:.2f}")


while True:
food = input("Select an item (q to quit): ").lower()
if food == "q":
break
elif menu.get(food) is not None:
cart.append(food)

YOUR ORDER
for food in cart:
total += menu.get(food)
print(food, end=" ")

print()
print(f"Total is: ${total:.2f}")

BroCodez
Автор

A perfect tutorial. Small real world examples really help get these ideas across for us lower class.

jasonherr
Автор

can we all just take a moment to appreciate these tutorials

AItechnologieswithallan
Автор

Bro i have got nothing else to say except you are THE BEST teacher i have ever learned from. Thank soooo much! Keep it up

eyalsilbershtein
Автор

I modified the code to allow the user to ask for the quantity. I used dictionary for the cart.

# Python concession stand program 🍿
# Concession stand program

menu = {"pizza": 3.00,
"nachos": 4.50,
"popcorn": 6.00,
"fries": 2.50,
"chips": 1.00,
"pretzel": 3.50,
"soda": 3.00,
"lemonade": 4.25}

cart = {}
total = 0

MENU
for key, value in menu.items():
print(f"{key:10}: ${value:.2f}")


while True:
food = input("Select an item (q to quit): ").lower()
if food == "q":
break
elif menu.get(food) is not None:
quantity = int(input("Enter how many servings: "))
cart.update({food: quantity})

print("---- YOUR ORDER ----")
for food, quantity in cart.items():
total += menu.get(food) * quantity
print(f"{quantity} x {food}")


print(f"Total is: ${total:.2f}")

stranger
Автор

bro your videos are great, i learned most of the hard parts easily from you, i just started python, i hope to be able to write programs like this with ease soon

isasenturk
Автор

THANK YOU SO MUCH!!! YOU GOT ME RISING UP FROM ROCK BOTTOM IN OUR CLASS! Thank you.

tributoandreanicoleb.
Автор

You are making a hell of a job here, sir. Thank you 😊

kapibara
Автор

Bro, love you from the core of my heart ❤️❤️❤️💯💯

curiouslife
Автор

I'm from India 🇮🇳
One word to say about bro, "ದೇವರು ನೀನು".

cinemaupd
Автор

thank you so much.your coding video really help me on my school project.😄

fawzan
Автор

if the item the user has selected is not in the menu, perhaps can add this
elif food not in menu.keys():
print("Item not on menu")

mister_cringe
Автор

Hey bro! I have been following your channel since two years now….
I really like your teaching method…
Your tutorials have helped me a lot…
I just wanted to ask can you please make a tutorial series for android and iOS app development…
Love from India 🇮🇳🧡

tanmaydevikar
Автор

Bro actual just helped me get an A on my tech

eno
Автор

I'm new to python, how do you make it so that you can purchase multiple items and then the accumulated total will be displayed in the order summary/reciept

rbl_crypto
Автор

Bro how can i put quantity for each food, like when I order 3 potatoes and compute total. ??

karlregio
Автор

Bro if i want to add menu iteams in shortcut key how do i do that?

uppubg
Автор

Bro can i use constructor for private class in c++?

curiouslife
Автор

Does it make difference if I didn't type "is not None" .. I wrote this code without this sentence..it gave me the same result 😅😅🙋‍♀️🤷‍♀️🤷‍♀️🙆‍♀️

xtehrun
Автор

For a sec, I thought it was "Ass Candy" 0:07 . I mean that's not a bad idea right?

SmurQx-jruk