What does this print?
print(type(3.14))
float
What does this print?
x = 10
if x > 5:
print("big")
big
What is the common short alias for NumPy?
np
What keyword defines a function?
def
What does this print?
print(type("hello"))?
'str'
What does this print?
int(3.9)
3
How many times does this loop run?
python
for i in range(3):
print(i)
3
What is the shape of np.array([1, 2, 3])?
(3,)
What does `return` do in a function?
Sends a value back to the caller and exits the function
What does this print?
x = 5
if x > 10:
print("a")
else:
print("b")
b
What is the value of my_list[1] if
my_list = [10, 20, 30] ?
20
What does this print?
x = 5
if x > 10:
print("a")
elif x > 3:
print("b")
else:
print("c")
b
What does this print?
arr = np.array([1, 5, 3])
print(arr > 2)
array([False, True, True])
What does `square(4)` return if:
def square(x):
return x * x
16
What does this print?
print(np.array([1, 2, 3]) * 2)
array([2, 4, 6]
How do you get the value in this dictionary?
data = {"weight": 30}
data["weight"]
What does this print?
i = 0
while i < 3:
print(i)
i += 1
0
1
2
What value should you use for "missing value" in NumPy?
np.nan
What does this print?
def add(a, b):
return a + b
print(add(3, 5))
8
What does this print?
def greet(name, msg):
print(msg, name)
greet("Alice", "Hi")
Hi Alice
What does this print?
print("5" + "3")
53
How do you write a comment in Python?
What does this print?
print(np.array([1, 2, 3]) * 10)
array([10, 20, 30])
In the following:
def greet(name, greeting="Hello"):
what is "Hello"?
Default value
What does this print?
x = [1, 2]
x.append(3)
print(len(x))