- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
# Adding two variables
a, b = "9", "30"
c = a + b
d = eval(a) + eval(b)
print(c, d)
- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
# Definite Loop
sum = 0
for i in [1, 2, 3, 4, 5]:
sum = sum + i
print(sum)
- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
# Definite Loop
sum = 0
for i in range(5):
sum = sum + i
print(sum)
- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
# Stars
for i in range(3):
for j in range(i):
print('*', end='')
print()