Functions 101
Functions 201
Random
Recursion
Double Jeopardy
100

def

What is ... the Python keyword used to DEF-ine (or to code or to create) a function?

100

None

What is ... the value all functions (in Python) return (if a return statement has not been coded in the function definition)?

100

print(type(None))

What is ... <class 'NoneType'>?

[FYI: This code was tested with JDoodle.]

100

[Hint: Definition]

recursion

What is ... when a function calls itself?

100

# [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?

200

return

What is ... the Python keyword used to code a return statement (or return statements) in a function definition?

200

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.]

200

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?

200

[Hint: Definition]

base case

What is ... the case when the recursion stops?

200

# [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?

300

parameter

What is ... the variable used in the function definition?

300

# 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.]

300

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?

300

If a recursive function has a bug or does not have a base case, the result is ... 

What is ... infinite recursion?

300

# [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.]

400

argument

What is ... the value passed to the function (parameter)?

400

Functions that can only be called with the name of the object (using dot notation)

What is ... a method?

400

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?

400

This mathematical algorithm (or operation) is a classic example of recursion. Commonly used to teach recursion.

What is ... factorial?

400

# [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.]

500

# 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.]

500

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.]

500

x = 0

a = []

while x <= 3:

     x *= 2

     a.append(x)

print(a)

What is ... infinite loop?

[FYI: This code was tested with JDoodle.]

500

Factorial can be coded using recurison or using ... another coding concept.

What is ... looping?

Or what is ... iteration?

500

# [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.]

M
e
n
u