In this video we learn how to create functions in Python.
This video is part of the Intro to Coding course, a free and open-source curriculum available for all classrooms to use. Intro to Coding was designed to introduce more schools and students into the computer technology fields. For more information visit https://github.com/isaiahkahler/intro...
Example Program:
drinks = [
'Coffee',
'Iced Coffee',
'Frozen Coffee',
'Macchiato',
'Cappuccino',
'Latte'
]
flavors = [
'Vanilla',
'Mocha',
'Caramel',
'No Flavor'
]
milks = [
'2% Milk',
'Skim Milk',
'Whole Milk',
'Nonfat Milk',
'Almond Milk',
]
additions = [
'Sugar',
'Espresso',
'Whipped Cream',
]
sizes = [
'Small',
'Medium',
'Large',
'Extra Large'
]
def menu(menu_list):
print the items
index = 1
for item in menu_list:
print(f'{index} - {item}')
index += 1
get user's choice
choice = input('choose an option:')
return the list option
return menu_list[int(choice) - 1]
print('welcome to the coffee shop')
drink = menu(drinks)
flavor = menu(flavors)
milk = menu(milks)
addition = menu(additions)
size = menu(sizes)
print()
print("Here's your order: ")
print(drink)
print(flavor)
print(milk)
print(addition)
print(size)
On this page of the site you can watch the video online Unit 4 Lesson 1 - Functions - Intro to Coding in Python with a duration of hours minute second in good quality, which was uploaded by the user Code Dog 30 September 2019, share the link with friends and acquaintances, this video has already been watched 157 times on youtube and it was liked by 4 viewers. Enjoy your viewing!