Tracing Assignment #1

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

Program a)

Step a b c Output

1 20

2 20 10

3 20 10 10

4 20 10 10 "unfair"

5 20 10 10 "unfair"

6 20 10 10 "unfair"

Program b)
Step n1 n2 ans i Output

1 Riverside Rocks! 0

2 Riverside Rocks! 0

3 verside cks! "RR" 0

4 verside cks! "RR" 1

5 rside s! "RRvc" 1

6 rside s! "RRvc" 2

7 de "RRvcrs" 2

8 de "RRvcrs" 3 "RRvcrs"

Program c)
Line n Output
n=3 3

if 1 < n and n < 4: 3

n=n+1 4

print n 4 4

elif n / 2 == 1: 4

print n 4

else: 4

print 5 4

while n < 5: 4

print n 4 4

n=n+1 5
while n < 5: 5

print n 5

n=n+1 6

while n < 5: 6

You might also like