x = 5
y = x + 3
print(y)
what is 8?
How many times does this loop print "Hello"?
for i in range(3):
print("Hello")
what is 3?
What will be printed?
x = 10
if x > 5:
print("Big")
else:
print("Small")
what is "Big"?
for i in range(5)
print(i)
Missing colon at the end of the for statement.
What is a variable?
A named place in memory to store data.
a = 2
b = 4
a = b
b = a + 3
print(a, b)
what is (4,7) ?
What is the final value of `count`?
count = 0
for i in range(1, 6):
count += i
what is 15?
What is the output?
num = 7
if num % 2 == 0:
print("Even")
else:
print("Odd")
what is "odd" ?
x = 10
if x = 5:
print("Five")
Uses `=` instead of `==` in the if condition.
What is a loop used for in programming?
To repeat a block of code multiple times.
def mystery(n):
total = 0
for i in range(1, n+1):
if i % 2 == 0:
total += i
return total
what is 6?
What does this code print?
for i in range(2):
for j in range(3):
print(i + j)
what is 0,1,2,1,2,3 ?
What does this code print?
a = 3
b = 5
if a > b:
print("A")
elif a == b:
print("Equal")
else:
print("B")
what is "B" ?
def add(a, b):
return a + b
print(add(2))
The function call is missing one argument.
What is the difference between a function and a loop?
A function is a reusable block of code that performs a specific task; a loop repeats code multiple times.