What will be the output of the following code?
x = 5
y = 10
print(x + y)
15
how many times will the following loop print hello?
for i in range(4):
print("Hello")
4 times
what will this code output?
x = 5
if x > 3:
print("Greater")
else:
print("Smaller")
greater
why does this code cause a error?
print(total)
total = 5
total is used before it is defined.
what is a variable?
A named location that stores data.
what is the output of this code snippet?
for i in range(3):
print(i * 2)
0,2,4
what is the output of this code?
x = 0
while x < 3:
print(x)
x += 1
0,1,2
what is the code of the following code?
age = 17
if age >= 18:
print("Adult")
elif age >= 13:
print("Teenager")
else:
print("Child")
teenager
what is the logical mistake?
for i in range(5):
print(i)
The print(i) line is not indented.
What is the difference between = and ==?
= assigns a value, while == compares values.
what will this code output?
x = 2
y = 3
if x == y:
print("Equal")
else:
print("Not Equal")
not equal
what will be the output of this code?
sum = 0
for i in range(1, 5):
if i % 2 == 0:
sum += i
print(sum)
6
what will be printed by this code?
x = -5
if x > 0:
print("Positive")
elif x < 0:
print("Negative")
else:
print("Zero")
negative
why does this loop never end ?
x = 1
while x < 5:
print(x)
x is never updated
What does “loop condition” mean?
The expression that determines whether a loop continues running.