- (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).
# Subtraction
def main():
sum = 666
for i = range(36):
sum = sum + i
print("sum = ", sum)
main()
- (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, 100, 2):
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).
# Simultaneous Assignment
N = 10
a, b = 0, 1
for i in range(N):
a, b = b, a+b
print(a)
- (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
import math
A = -3.6
print( int(A) )
print( round(A) )
print( math.floor(A) )
print( math.ceil(A) )