Python Basics
If-Else & Booleans
Loops
Finch Methods
Mystery
100

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.

100

What's the output?

condition = True

if not condition:
   print(condition)
else:
   print(not condition)

False

100

What is wrong with the following code?

count = 3

while count > 0:
count = count + 1

Infinite loop, count is always > 0

100

This Finch method prints values on the micro:bit LEDs.

finch.print()

100

The function we use to check the data type of a variable/value.

type( )

200

What is the data type of variable x?


x = 5 // 2

int

200

The logical operator that validates/checks if two conditions are both true.

and

200

What sequence of numbers does this range( ) function produce?

range(5, -1, -1)

5, 4, 3, 2, 1

200

In Finch's playNote( ) method, the beats parameter is equal to this unit of time.

seconds

200

What gets displayed?

num = round(5.3479, 3)
print(num)

5.348

300

What gets displayed?

x = "4"
y = 2

print(y * x)


44 (string concatenation)

300

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

300

Explain the difference between break and continue.

break exits and stops a loop completely,
continue only skips the current iteration of a loop.

300

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)

300

The 'JS' in 'JSON' stands for:

Javascript

400

What is the output?

x = 5 * (3 + 3) / 3

print(x)

10.0

400

What will be displayed?

name = "Mario"
x = "Luigi"
name = x

if name == "Luigi":
   print("Luigi " + "Mario")
elif name == "Mario":
   print("Mario " + "Mario")

Luigi Mario

400

How many times is '*' displayed?

count = 3
while count > 1:
   print("*")
   while count > 0:
      print("*")
      count = count - 1

4 times

400

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

400

What are the values in the parentheses referred as?

def my_function(x, y):
   return x + y

my_function(6 + 7)

parameters/arguments

500

What's wrong with the following code? 

print("Today's date is " + 5 + "/" + 26)

Cannot concatenate str with int

500

How many * will be printed?

x = 5

if x / 5 == 1:
   print("*")
if x == 5:
   print("*")
elif 25 / 5 == x:
   print("*")

2

500

What numbers get printed?

for i in range(1, 10):
   if i % 3 == 0:
     continue
   print(i)

1, 2, 4, 5, 7, 8

500

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 

500

Mr. G graduated from California State University - __________ ____

Monterey Bay