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

Pubblicato il: 30 settembre 2019
sul canale di: 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)


In questa pagina del sito puoi guardare il video online Unit 4 Lesson 1 - Functions - Intro to Coding in Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Code Dog 30 settembre 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 157 volte e gli è piaciuto 4 spettatori. Buona visione!