- (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).
# print(objects, sep='', end='\n')
for i in range(1, 6, 2):
print(i, i+1, sep=',')
- (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).
# Type Conversion
# int() will truncate the fractional part
a = 4.8
b = a + 0.5
print(a, int(a))
print(-a, int(-a))
print(b, int(b))
print(-b, int(-b))
- (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).
# Accumulator
sum = 0
for i in range(1, 6):
sum = sum + i
print(i, sum)