What word do you type to make Python show something on the screen?
What keyword starts a loop that repeats through a sequence of values?
for
What keyword repeats code as long as a condition stays True?
while
What keyword checks whether something is true and makes a decision?
if
for i in range(3):
print("Go!")Go! printed three times (on three lines)
True or False: What should you ALWAYS DO for all the code inside of a for/while loop?
INDENT!
What numbers does range(5) produce?
0, 1, 2, 3, 4
A loop that never stops because its condition is always True is called this.
an infinite loop
= sets the value for the variable
== sees if two things are equivalent to eachother or not
total = 0
for i in range(4):
total = total + 1
print(total)
4
What's the difference between single quotes 'a' and double quotes "a"?
'a' is for a char! and "a" is for a string!
How many times does the body run in for i in range(3):
3 times
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
What keyword runs the "otherwise" code when the if is False?
else
for i in range(1, 4):
print(i)
1,2,3 (each on its own line)
What does print("5" + "3") show on screen?
53
What numbers does range(1, 6) give you?
1, 2, 3, 4, 5
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
In an if / elif / elif / else chain, how many of the blocks actually run?
exactly one
x = 5
if x == 5:
x=x*5
print("yes" + str(x))
else:
print("no" + str(x))
yes25
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
What numbers does range(0, 10, 2) produce?
0, 2, 4, 6, 8
What three components are loops made up of?
What does this print?
x = 8
if x > 10:
print("big")
elif x > 5:
print("medium")
else:
print("small")medium!
total = 0
for i in range(1, 4):
total = total + i
print(total)