x = 10
x = x + 5
print(x); What is the output?
15 is the right answer
for i in range(3):
print(i)
0, 1, 2
x = 7
if x > 5:
print("Greater")
else:
print("Smaller")
It would be greater
x = 3
y = 5
if x > y:
print("x is greater")
else:
print("y is greater")
Nothings wrong
What is a variable
A variable holds value
a = 3
b = 4
a = a * b
b = a - b
print(b): What is the final value of b?
8
total = 0
for i in range(1, 6):
total += i
print(total)
15
x = 8
if x % 2 == 0:
print("Even")
else:
print("Odd")
It would be even
x = 4
if x = 4:
print("Equal")
= is used instead of ==
What does a loop do?
A loop repeats the code
x = 5
y = 3
x = x * y
y = x + y
x = x - y
print(x)
-3
total = 0
for i in range(2, 11, 2):
total += i
print(total)
30
x = 4
y = 7
if x < y:
if x % 2 == 0:
print("Even")
else:
print("Odd")
else:
print("Not even")
It would be even
x = 5
y = 2
if x > y:
print("x is bigger")
the line of code for print is not spaced correctly
What is the purpose of an if statement?
It makes decisions in a program.