Sep-19-2020, 05:30 AM
1. (a) Trace (by hand) the execution of the following Python program by completing
the trace table below. For Each line of code (as labelled with line numbers), you
would enter the line number in the trace table, the state/value of the variable(s)
that is/are affected within that line, and any output displayed by that line.
Note: Tracing a program with test data is a good mechanism to see if your code
is working.
Python program:
Trace table:
Line number x y v z w Output
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Note: to submit your solution for this question you can create a new file in idle
and save it with a .txt extension (rather than a .py extension).
I don't get what am I supposed to do.
the trace table below. For Each line of code (as labelled with line numbers), you
would enter the line number in the trace table, the state/value of the variable(s)
that is/are affected within that line, and any output displayed by that line.
Note: Tracing a program with test data is a good mechanism to see if your code
is working.
Python program:
from math import * x = 13 #LINE 1 y = 2 #LINE 2 v = 120 #LINE 3 z = 9.0 #LINE 4 w = 1.15 #LINE 5 w = (x//y*100) #LINE 6 v = x/y*100 #LINE 7 w = w/1000 #LINE 8 v = int(w+999/1000) #LINE 9 w = 2.5+4*-1.5-(2.5+4)*-1.5 #LINE 10 x += 1 #LINE 11 w = x%y * pow(x*y/4,y) #LINE 12 v = int((6+int(w))/x ) #LINE 13 w = x*float(20/8) #LINE 14 a = y%x #LINE 15 print("Sum of w,x,y is: " + ’w+x+y’) #LINE 16 print("Price per litre is $%.2f" %((w+x+y+z)% 59)) #LINE 17 b = "Supercalifragilisticexpialidocious" #LINE 18 c = len(b) #LINE 19 d = b[0:5]+" "+b[27].upper()+b[3]+b[7]+b[8]+b[-5:] #LINE 202
Trace table:
Line number x y v z w Output
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Note: to submit your solution for this question you can create a new file in idle
and save it with a .txt extension (rather than a .py extension).
I don't get what am I supposed to do.