Python basics
For Loops
While Loops
If / Elif / Else
What's the output?
100

What word do you type to make Python show something on the screen?

print

100

What keyword starts a loop that repeats through a sequence of values?

for

100

What keyword repeats code as long as a condition stays True?

while

100

What keyword checks whether something is true and makes a decision?

if

100
for i in range(3):
     print("Go!")


Go! printed three times (on three lines)

200

True or False: What should you ALWAYS DO for all the code inside of a for/while loop?

INDENT!

200

What numbers does range(5) produce?

0, 1, 2, 3, 4

200

A loop that never stops because its condition is always True is called this.

an infinite loop

200
What is the difference between one "=" and two "=="?

= sets the value for the variable

== sees if two things are equivalent to eachother or not

200

total = 0
 for i in range(4):
     total = total + 1
 print(total)


4

300

What's the difference between single quotes 'a' and double quotes "a"?

'a' is for a char! and "a" is for a string! 

300

How many times does the body run in for i in range(3):

3 times

300

Name the three things a safe while loop needs.

a starting value, a condition that will eventually become False, and something inside the loop that changes the value

300

What keyword runs the "otherwise" code when the if is False?

else

300

for i in range(1, 4):
     print(i)

1,2,3 (each on its own line)

400

What does print("5" + "3") show on screen?

53

400

What numbers does range(1, 6) give you?

1, 2, 3, 4, 5

400

What's wrong with this loop?

 count = 0 

while count < 5:     

print(count)

it's an infinite loop — count never changes, so it never reaches 5

400

In an if / elif / elif / else chain, how many of the blocks actually run?

exactly one

400

x = 5
 if x == 5:

     x=x*5
     print("yes" + str(x))
 else:
     print("no" + str(x))


yes25

500

What is it called when we wrap the output from input() into an int(), meaning we change it from a string to an int?

Concatenation

500

What numbers does range(0, 10, 2) produce?

0, 2, 4, 6, 8

500

What three components are loops made up of?

Control variable, conditional expression, loop expression
500

What does this print?

 x = 8
 if x > 10:
     print("big")
 elif x > 5:
     print("medium")
 else:
     print("small")


medium!

500

 total = 0
 for i in range(1, 4):
     total = total + i
 print(total)


6