Recursion
Strings
Iteration
Functions
Misc
100

Recursive functions use this to stop recursive calls

What is the base case?

100

The keyword reserved for strings

What is str?

100

While loops take a _______ value to decide whether or not they repeat

What is a boolean value

100

The keyword used to define a function

What is def

100

Why can you not access variables declared inside a function outside of it?

What is scope

200

The method to track recursive function calls

What is substitution trace 

200
A way to access the last character of a String of unknown length in python through splicing

what is s[-1:]

200

The method to track a variable between iterations

What is timeline trace

200

The name of the variables declared in the function header

What is parameter

200

Define declaring a variable

The process of telling the program that a specific variable exists and what it's name is. 

300

Define tail recursion

What is a specific type of recursion where the recursive call is the absolute last operation performed by the function before it returns 

300

How can you reverse a string with splicing?

what is [::-1]

300

This keyword ends the loop completely, even before its conditions are fulfilled. 

What is break

300

Functions return this when there is no return statement

What is None?

300

The purpose of a main guard

its purpose is to control whether code runs automatically or only when the file is executed directly.

400

This happens when you call a recursive function too many times within itself.

What is a RecursionError

400

How does string splicing work?

Slicing lets you pull out a substring using the pattern: s[start:stop:step]

400

Rewrite this while loop as a for loop:

j = 0

while j < 77:

    print("I'm currently", j, "years old")

    j += 1

for j in range(77):
    print("I'm currently", j, "years old")

400

This keyword is used inside a function to send a value back to the code that called it, immediately ending the function's execution at that point.

What is return

400

Free points! First to tell me their favorite board game wins!

Ark nova

500

The substitution trace of this function:

def board(game):

    if (game == 0):

        return "DONE"

    if (game % 2 == 0):

        return "J" + board(game - 1)

    if (game > 5):

         return "A" + board(game - 1)

    if (game % 2 == 1):

        return "L" + board(game - 1)


board(7)

board(0) = "DONE"
board(1) = "L" + board(0) = "L" + "DONE"              = "LDONE"
board(2) = "J" + board(1) = "J" + "LDONE"              = "JLDONE"
board(3) = "L" + board(2) = "L" + "JLDONE"             = "LJLDONE"
board(4) = "J" + board(3) = "J" + "LJLDONE"            = "JLJLDONE"
board(5) = "L" + board(4) = "L" + "JLJLDONE"           = "LJLJLDONE"
board(6) = "J" + board(5) = "J" + "LJLJLDONE"          = "JLJLJLDONE"
board(7) = "A" + board(6) = "A" + "JLJLJLDONE"         = "AJLJLJLDONE"

500

What would be printed out by this code:

board = "game"

gamer = "board"

print(gamer[::-1] + board[0:5] + gamer[1:2])

what is draobgameo

500

Rewrite this recursive function iteratively 

def sum_up_to(n, total=0):
    if n == 0:
        return total
    return sum_up_to(n - 1, total + n)

print(sum_up_to(5))

def sum_up_to_loop(n):
    total = 0
    while n != 0:
        total = total + n
        n = n - 1
    return total

print(sum_up_to_loop(5))

500

Write code of a function named "ark" with parameters "no" and "va" which multiplies both together and then adds the original values. Also call the function with the arguments "5" and "7"

def ark(no, va):
    return (no * va) + no + va

ark(5, 7)

500

Write some code that opens file "boardgame.txt" and automatically closes it

with open( "boardgame.txt" ) as fd :

        # doesn't matter

M
e
n
u