def agree():
return True
if agree():
print('Splendid!')
else:
print('That was unexpected')Splendid!
def agree():
return False
if agree():
print('Splendid!')
else:
print('That was unexpected')That was unexpected
def echo(anything):
return anything + ' ' + anything
print(echo("Rumplestiltskin"))Rumplestiltskin Rumplestiltskin
The values you pass into a function when you call it are known as ___
arguments
Arguments are inside the function and ___ are outside the function
parameters
def commentary(color):
if color == 'red':
return "It's a tomato."
elif color == "green":
return "It's a green pepper."
elif color == "bee purple":
return "I dont know what it is, but only bees can see it."
else:
return "I've never heard of the color " + color + "."
comment = commentary('blue')
print(comment)I’ve never heard of the color blue.
thing = None bool(thing) print(bool(thing))
False
thing = None
if thing:
print("It's some thing")
else:
print("It's no thing")It’s no thing
thing = 0 print(bool(thing))
False
thing = 0 print(thing == False)
True
thing = 0 print(thing is False)
False
thing = 1 print(bool(thing))
True
thing = 1 print(thing == True)
True
thing = 1 print(thing is True)
False
def whatis(thing):
if thing is None:
print("None")
elif thing:
print("true")
else:
print("false")
whatis(None)None
def whatis(thing):
if thing is None:
print(“None”)
elif thing:
print(“true”)
else:
print(“false”)
whatis(True)
true
def whatis(thing):
if thing is None:
print("None")
elif thing:
print("true")
else:
print("false")
whatis(False)false
def whatis(thing):
if thing is None:
print("None")
elif thing:
print("true")
else:
print("false")
whatis(0)false
def whatis(thing):
if thing is None:
print("None")
elif thing:
print("true")
else:
print("false")
whatis(0.0)false
def whatis(thing):
if thing is None:
print("None")
elif thing:
print("true")
else:
print("false")
whatis('')false
def whatis(thing):
if thing is None:
print("None")
elif thing:
print("true")
else:
print("false")
whatis("")false
def whatis(thing):
if thing is None:
print("None")
elif thing:
print("true")
else:
print("false")
whatis('''''')false
def whatis(thing):
if thing is None:
print("None")
elif thing:
print("true")
else:
print("false")
whatis(())false
def whatis(thing):
if thing is None:
print("None")
elif thing:
print("true")
else:
print("false")
whatis([])false