Functions
Lists
For loops
2D Lists
Dictionaries, Tuples, Sets
100

What is `age` called the following code

def can_drive(age):

    return age >= 18

parameter

100

Define a variable x that is a list with 2 items

x = [3, 4]

100

In the following loop. What should replace [missing]?

for i [missing] range(4):

   print(i)

in

100

What is the length of table

table = [['Popeye', 20], ['Jelly', 200]]

2

100

Define a variable called 's' that contains a new empty dictionary

s = {}

200

What does the following print

def mystery(val)

    return (val * 2) - 3

x = mystery(5)

print(mystery(x))

11

200
Given a list named `players` write code to print out its length

print(len(players))

200

Write a for loop to print out all items from `shows`

shows = ['DS9', 'Enterprise', 'Next Generation']


for s in shows:

    print(s)

200

How can you determine if something is a 2D list

A list that only contains other lists

200

How can you determine whether a value is a tuple?

A list of values separated by commas surrounded by parenthesis

300

What is the order that the following lines of code will be executed:

1. def multiply_5(num):

2.     return num * 5

3. x = multiply_5(20)

4. print(x)

1, 3, 1, 2, 3, 4

300

Why would you use a list instead of a tuple?

You cannot mutate a tuple

300

What does the following print?

prices = {'bananas': 4, 'apples': 2, 'oranges': 5}

for c in prices:

    if prices[c] % 2 == 0:

        print(c)

bananas

apples

300

What is the value of x

board = [['B', 'E', 'M', 'O'], ['F', 'I', 'N', 'N'], ['J', 'A', 'K', 'E']]

x = board[1][2]

N

300

Given a dictionary named `player_numbers` add a new key: 34, with the value 'Giannis'

player_numbers[34] = 'Giannis'

400

Define a function that takes two parameters, a list and a number. The function should return true if the length of the list greater than the number

def func(lst, num):

    return len(lst) > num

400

Write code to loop through a list `numbers` and create a new list `over_ten` that contains all values in `numbers` that are greater than 10

over_ten = []

for n in numbers:

  if n > 10:

    over_ten.append(n)

400

When can you not use a for loop to execute a block of code a number of times

When you don't know how long you are going to loop

400

Write the code to change the value 'Hey' in the list below to 17

table = [[55, 100, 22], [45, 33, 11], ['Hey', 2, 111]]


table[2][0] = 17

400

How many keys does `scores` have after the following code:

scores = {'sam': 50, 'legolas': 25}

scores['gimli'] = 99

scores[25] = 'gandalf'

4