What will this code print? Figure it out by hand, then run the code to confirm. Then slightly edit the code and try again.
- Trace #1 of 3:
def ct1(m, n):
total = 0
for x in range(m, n+1, 3):
print('x =', x)
total += x
for y in range(m, m+2):
print('y = ', y)
total += y
return total
print(ct1(1,9))
- Trace #2 of 3:
def ct2(n):
k = 0
total = 0
while (n >= k):
print('k =', k)
for i in range(k):
total += n%10
n //= 10
print(i, n%10, total)
k += 1
print('total =', total)
print(ct2(1234))
- Trace #3 of 3:
def ct3(z):
total = 0
for y in range(z,1,-1):
if (y % 2 == 0):
print('skip y =', y)
continue
total += y
if (total > 20):
print('break at y =', y)
break
return total
print(ct3(10))