What data type is the variable num?
num = 10
int data type
What is the code inside a function called?
Function body.
What distinguishes an if statement from an else?
(What is one thing that an if statement has more than an else?)
An executing condition.
What functionality is used in Python to repeat a segment of code multiple times?
A for loop.
What data type allows you to input more specific numbers that include decimal points.
floats
What data type is the variable var1?
var1 = 'hello'
var1 is a string
What is this function doing?
def mystery(x, n):
return x**n
Returning a power:
xn
What conditional function allows you to add more condition checks beyond the initial if statement?
An else if conditional.
What functionality is used in Python is used to repeat code based on a condition.
A while loop.
What is David's starting Pokemon choice?
Bulbasaur
What data type is the variable test after casting?
test = str(float(123))
test is a string after casting is performed.
What imported module allows us to use functions such as pow (power) and gcd (greatest common divisor)?
Math module.
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'
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.
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.
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.
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.
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
Which data type is immutable in Python and most programming languages?
The string data type is immutable.