Skip to content

Instantly share code, notes, and snippets.

@joao141141
Created February 9, 2024 06:26
Show Gist options
  • Save joao141141/43d482281d047d5656232fd3fadf5594 to your computer and use it in GitHub Desktop.
Save joao141141/43d482281d047d5656232fd3fadf5594 to your computer and use it in GitHub Desktop.
My first Chat Bot
# Define your functions
def coffee_bot():
print('Welcome to the cafe!')
size = get_size()
print(size)
drink_type = get_drink_type()
print(drink_type)
print('Alright, that\'s a {} {}!'.format(size, drink_type))
extra_options()
name = input('Can I get your name please?\n>')
print('Thanks, {}! Your drink will be ready shortly.'.format(name))
def print_message():
print('I\'m sorry, I did not understand your selection. Please enter the corresponding letter for your response.')
def get_drink_type() -> str:
res = input('What type of drink would you like? \n[a] Brewed Coffee \n[b] Mocha \n[c] Latte \n>')
if res == 'a':
return 'brewed coffee'
elif res == 'b':
return 'mocha'
elif res == 'c':
return get_order_latte()
else:
print_message()
return get_drink_type()
def get_order_latte() -> str:
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 'latte with 2% milk'
elif res == 'b':
return 'non-fat latte'
elif res == 'c':
return 'soy latte'
else:
print_message()
return get_order_latte()
def get_size() -> str:
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 extra_options():
res = input('Would you like a plastic cup or did you bring your own reusable cup? \n[a] I\'ll need a cup. \n[b] Brought my own! \n> ')
if res == 'a':
print('Okay, no problem! We\'ll get you a plastic cup.')
elif res == 'b':
print('Great! We\'ll fill up your reusable cup.')
else:
print_message()
return extra_options()
coffee_bot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment