Unit 4 Lesson 1 - Functions - Intro to Coding in Python

Veröffentlicht am: 30 September 2019
auf dem Kanal: Code Dog
157
4

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)


Auf dieser Seite können Sie das Online-Video Unit 4 Lesson 1 - Functions - Intro to Coding in Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Code Dog 30 September 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 157 Mal angesehen und es wurde von 4 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!