Variables/Types
Functions
Conditionals
Loops
Bonus
100

What data type is the variable num?

num = 10

int data type

100

What is the code inside a function called?

Function body.

100

What distinguishes an if statement from an else?

(What is one thing that an if statement has more than an else?)

An executing condition.

100

What functionality is used in Python to repeat a segment of code multiple times?

A for loop.

100

What data type allows you to input more specific numbers that include decimal points.

floats

200

What data type is the variable var1?

var1 = 'hello'

var1 is a string

200

What is this function doing?

def mystery(x, n):

   return x**n

Returning a power:
xn

200

What conditional function allows you to add more condition checks beyond the initial if statement?

An else if conditional.

200

What functionality is used in Python is used to repeat code based on a condition.

A while loop.

200

What is David's starting Pokemon choice?

Bulbasaur

300

What data type is the variable test after casting?

test = str(float(123))

test is a string after casting is performed.


300

What imported module allows us to use functions such as pow (power) and gcd (greatest common divisor)?

Math module.

300

Which conditional branch will this code execute into and what will it return?

number = 1234567890

if number % 2 == 1:

   return 'odd'

else:

   return 'even'

else branch, will return 'even'

300

How many times will the following loop body execute in the for loop and what will the return value be of total?

numbers = [0, 12, 40, 2]

total = 0

for num in numbers:

    total = total + num

return total



The loop body will execute 4 times as there are 4 elems in numbers.

The return value of total will be 54.

300

What is the difference between an index based for loop and a range based for loop?

Index: loops over specific number of elements in a given input.

Range: loops for specific number of iterations based on an inputted range.

400

What data type is challenge after casting?

one = 12 two 13 three = 14 challenge = list(float(one), float(two), float(three))

challenge is a list of floats after casting is performed.

400

What will this code snippet return after it runs?

epsilon = 0

if epsilon % 2 == 0:

   if epsilon % 3 == 1:

      return False

   elif epsilon % 3 == 0:

       return True

   else:

       return epsilon

This code snippet will return the boolean True after it runs.

400

What is the output?


run = [2, 4, 8, 0, 1, 3, 4]

total = 0

while run[i] % 2 == 0:

          total += run[i]


return total

          


total = 14

400

Which data type is immutable in Python and most programming languages?

The string data type is immutable.