What is printed by the following code?
x = 3
x = x + 2
print(x)
5
Why does an if statement allow a computer to make a decision?
Because it checks a condition and chooses between two outcomes.
What is printed by the following code?
num = 4
if num > 0:
print("Positive")
else:
print("Negative")
Positive
What is wrong with the code?
if age = 16:
print("Can drive")
The assignment operator = is used instead of ==.
What is a string?
Text data written inside quotation marks.
What is printed?
x = 10
y = x - 4
x = y + 1
print(x)
7
What happens if multiple if statements are used instead of if / elif?
More than one condition could run.
What is printed 🥺👀
x = 10
if x < 5:
print("A")
elif x < 15:
print("B")
else:
print("C")
B
What is wrong with the code below?
print("Hello world)
The closing quotation mark is missing.
Why do we use int() with input?
To convert the input from a string into a number.
What is printed?
a = 5
b = a
a = a + 3
print(b)
5
Why is elif better than multiple else if ideas?
It checks conditions in order and stops once one is true.
What is printed
x = 8
if x % 2 == 0:
if x > 10:
print("Big Even")
else:
print("Small Even")
else:
print("Odd")
Small even
What is wrong in the following code?
Age = input("How old are you?")
if age >= 16:
print("You can drive")
The variable name does not match (Age vs age).
What is a logic error?
When the code runs but produces the wrong result.