def
What is ... the Python keyword used to DEF-ine (or to code or to create) a function?
None
What is ... the value all functions (in Python) return (if a return statement has not been coded in the function definition)?
print(type(None))
What is ... <class 'NoneType'>?
[FYI: This code was tested with JDoodle.]
[Hint: Definition]
recursion
What is ... when a function calls itself?
# [Double Jeopardy: 200 Points]
# Hint: Not the output.
my_list = ["Lenny", "Joey", "Danny"]
if "Lenny" in my_list:
print("'Lenny' is in the list")
# Output: 'Lenny' is in the list.
How ... do you check if an item (or element) is in a list?
return
What is ... the Python keyword used to code a return statement (or return statements) in a function definition?
print("What am I?")
print(str(42))
print(type(None))
What is ... a built-in function?
Or what are ... built-in functions?
[FYI: This code was tested with JDoodle.]
pass
What is ... the Python keyword that allows you code (or define) a function without a body (a block of code), without generating an error?
[Hint: Definition]
base case
What is ... the case when the recursion stops?
# [Double Jeopardy: 400 Points]
def fun_tw(fun, arg):
return fun(fun(arg))
def twice(x):
return x * x
print(fun_tw(twice, 2))
What is ... 16?
parameter
What is ... the variable used in the function definition?
# Hint: Not the output.
# The method.
list = ['apple', 'banana', 'carrots']
list.pop(2)
print(list)
What is ... the pop() method?
Or what is ... pop()?
[FYI: This code was tested with JDoodle.]
Lists are useful because ...
What is ... can store multiple data items (usually of the same data type) that are related used to solve a specific problem?
If a recursive function has a bug or does not have a base case, the result is ...
What is ... infinite recursion?
# [Double Jeopardy: 600 Points]
# Hint: The output
if 5 > 2:
print("Five is greater than two!")
What is ... IndentationError?
[FYI: This code was tested with JDoodle.]
argument
What is ... the value passed to the function (parameter)?
Functions that can only be called with the name of the object (using dot notation)
What is ... a method?
my_string = "!skcor nuH .rM"
my_string = my_string[::-1]
print(my_string)
# Hint: Not the output
What is ... the "secret formula" to reverse a string?
Or how do you reverse a string in Python?
This mathematical algorithm (or operation) is a classic example of recursion. Commonly used to teach recursion.
What is ... factorial?
# [Double Jeopardy: 800 Points]
# Fill in the ______.
_____ min(egg, ham):
if egg <= ham_
return egg
else:
_____ ham
What is ... def, colon, return?
Or what is ... def and colon and return?
[FYI: This code was tested with PythonTutor.]
# Output: ???
# Scan the code carefully.
def my_func(egg, spam):
if egg != 0 and spam != 0:
return egg * spam
print(my_func(0, 6))
What is ... None?
[FYI: NOT 0 (zero). NOT no output. This code was tested with JDoodle & PythonTutor.]
def my_func(beans):
if beans != "":
return beans == beans[::-1]
string1 = "madamimadam"
print(my_func(string1))
# Output: ???
What is ... True?
[FYI: This code was tested with JDoodle.]
x = 0
a = []
while x <= 3:
x *= 2
a.append(x)
print(a)
What is ... infinite loop?
[FYI: This code was tested with JDoodle.]
Factorial can be coded using recurison or using ... another coding concept.
What is ... looping?
Or what is ... iteration?
# [Double Jeopardy: 1,000 Points]
# Hint: The output.
def my_func(beans):
spam = 0
for egg in range(beans):
spam += egg
return spam
print(my_func(4))
What is ... 6?
[FYI: This code was tested with PythonTutor.]