T/F: This is a valid name for a variable: break.
False
break is a special Python keyword, so we are not allowed to use it as a variable.
What's the output?
condition = True
if not condition:
print(condition)
else:
print(not condition)
False
What is wrong with the following code?
count = 3
while count > 0:
count = count + 1
Infinite loop, count is always > 0
This Finch method prints values on the micro:bit LEDs.
finch.print()
The function we use to check the data type of a variable/value.
type( )
What is the data type of variable x?
x = 5 // 2
int
The logical operator that validates/checks if two conditions are both true.
and
What sequence of numbers does this range( ) function produce?
range(5, -1, -1)
5, 4, 3, 2, 1
In Finch's playNote( ) method, the beats parameter is equal to this unit of time.
seconds
What gets displayed?
num = round(5.3479, 3)
print(num)
5.348
What gets displayed?
x = "4"
y = 2
print(y * x)
44 (string concatenation)
x = JSON stands for Javascript Object Notation.
y = Mr. G became the new CS1 teacher in March.
The boolean expression not (not (x or y)) evaluates to:
True
Explain the difference between break and continue.
break exits and stops a loop completely,
continue only skips the current iteration of a loop.
This function/method call will make Finch's left wheel move forward at a speed of 30 and its right wheel move forward at a speed of 60.
finch.setMotors(30, 60)
The 'JS' in 'JSON' stands for:
Javascript
What is the output?
x = 5 * (3 + 3) / 3
print(x)
10.0
What will be displayed?
name = "Mario"
x = "Luigi"
name = x
if name == "Luigi":
print("Luigi " + "Mario")
elif name == "Mario":
print("Mario " + "Mario")
Luigi Mario
How many times is '*' displayed?
count = 3
while count > 1:
print("*")
while count > 0:
print("*")
count = count - 1
4 times
This code is supposed to make the Finch move forward until it is 15cm away from an obstacle. There's a mistake. What is it?
finch = Finch()
finch.resetEncoders()
while finch.getDistance():
finch.setMotors(20, 20)
finch.stop()
Infinite loop, no comparison was made with the Finch's getDistance() method.
while finch.getDistance() > 15
What are the values in the parentheses referred as?
def my_function(x, y):
return x + y
my_function(6 + 7)
parameters/arguments
What's wrong with the following code?
print("Today's date is " + 5 + "/" + 26)
Cannot concatenate str with int
How many * will be printed?
x = 5
if x / 5 == 1:
print("*")
if x == 5:
print("*")
elif 25 / 5 == x:
print("*")
2
What numbers get printed?
for i in range(1, 10):
if i % 3 == 0:
continue
print(i)
1, 2, 4, 5, 7, 8
By running this code, the Finch will draw a ______ shape a total of ___ times.
for i in range(4):
for i in range(5):
finch.setMove("F", 20, 75)
sleep(0.5)
finch.setTurn("R", 108, 50)
sleep(0.5)
pentagon, 4
Mr. G graduated from California State University - __________ ____
Monterey Bay