- (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).
# Pre-test (P.236)
i = 1
while i < 9:
print(i)
i = i + 2
- (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).
# Loop and a Half (P.254)
i = 1
while True:
i = i + 2
if i == 9: break
print(i)
- (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).
# Nested Loops (P.244)
K = 5
i = 1
while i <= K:
j = K - i
while j > 0:
print(end=' ')
j = j - 1
j = i
while j > 0:
print('*', end='')
j = j - 1
print()
i = i + 1