-
-
Save codecademydev/02fbf16e0d88b6c64e7f64aac793dbcd to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def coffee_bot(): | |
print('Welcome to the cafe!') | |
order_drink = "y" | |
drinks = [] | |
while order_drink == "y": | |
size = get_size() | |
drink_type = get_drink_type() | |
drink = '{} {}'.format(size, drink_type) | |
print('Alright, that\'s a {}!'.format(drink)) | |
drinks.append(drink) | |
while True: | |
order_drink = input("Would you like to order another drink? \n[a] y \n[b] n \n>") | |
if order_drink == "y" or "n" or "yes" or "sure" or "no": | |
break | |
print('Okay, so I have:') | |
for drink in drinks: | |
print('-', drink) | |
name = input('Can I get your name please? \n> ') | |
print('Thanks, {}! Your order will be ready shortly.'.format(name)) | |
coffee_bot() | |
def get_drink_type(): | |
res = input('What type of drink would you like? \n[a] Brewed Coffee \n[b] Mocha \n[c] Latte \n> ') | |
if res == 'a': | |
return order_brewed_coffee() | |
elif res == 'b': | |
return order_mocha() | |
elif res == 'c': | |
return order_latte() | |
else: | |
print_message() | |
return get_drink_type() | |
def print_message(): | |
print('I\'m sorry, I did not understand your selection. Please enter the corresponding letter for your response.') | |
def get_size(): | |
res = input('What size drink can I get for you? \n[a] Small \n[b] Medium \n[c] Large \n> ') | |
if res == 'a': | |
return 'small' | |
elif res == 'b': | |
return 'medium' | |
elif res == 'c': | |
return 'large' | |
else: | |
print_message() | |
return get_size() | |
def order_latte(): | |
res = input('And what kind of milk for your latte? \n[a] 2% milk \n[b] Non-fat milk \n[c] Soy milk \n> ') | |
if res == 'a': | |
return 'ordinary latte with 2% milk' | |
elif res == 'b': | |
return 'non-fat latte' | |
elif res == 'c': | |
return 'soy latte' | |
else: | |
print_message() | |
return order_latte() | |
# Define new functions here! | |
def order_brewed_coffee(): | |
while True: | |
res = input("Would you like to try coffee brewed from the finest Brazilian grounds? \n[a] Yes! \n[b] No way, Mister! \n>") | |
if res == "a": | |
return "Brazilian grounds coffee" | |
elif res == "b": | |
return "ordinary brewed coffee" | |
print_message() | |
def order_mocha(): | |
while True: | |
res = input("Would you like to try our limited-edition peppermint mocha? \n[a] Sure! \n[b] Maybe next time! \n>") | |
if res == "a": | |
return "peppermint mocha" | |
elif res == "b": | |
return "mocha" | |
print_message() | |
coffee_bot() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_message(): | |
print('I\'m sorry, I did not understand your selection. Please enter the corresponding letter for your response.') | |
def get_size(): | |
res = input('What size drink can I get for you? \n[a] Small \n[b] Medium \n[c] Large \n> ') | |
if res == 'a': | |
return 'small' | |
elif res == 'b': | |
return 'medium' | |
elif res == 'c': | |
return 'large' | |
else: | |
print_message() | |
return get_size() | |
def order_latte(): | |
res = input('And what kind of milk for your latte? \n[a] 2% milk \n[b] Non-fat milk \n[c] Soy milk \n> ') | |
if res == 'a': | |
return 'ordinary latte with 2% milk' | |
elif res == 'b': | |
return 'non-fat latte' | |
elif res == 'c': | |
return 'soy latte' | |
else: | |
print_message() | |
return order_latte() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment