Which Python keyword indicates the start of a function definition?
What does the following code
print out?
def thing():
print('Hello')
print('There')
x = 'banana'
y = max(x)
print(y)
def func(x) :
print(x)
func(10)
func(20)
def stuff():
print('Hello')
return
print('World')
stuff()
What will the following Python
program print out?
def greet(lang):
if lang == 'es':
return 'Hola'
elif lang == 'fr':
return 'Bonjour'
else:
return 'Hello'
print(greet('fr'),'Michael')
What does the following Python
code print out? (Note that this is a bit of a trick question and the code has
what many would consider to be a flaw/bug - so read carefully).
def addtwo(a, b):
added = a + b
return a
x = addtwo(2, 7)
print(x)
What is the most important benefit of writing your own functions?