Python Tracing问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 11:02:48
请问在Python里什么是tracing?

明天考试要考tracing 练习的时候就是几个简单的exercises 要求一行一行的分析 可我还是不明白到底什么是tracing?如果考试(不是在电脑上)时有tracing的题要怎么做?

非常感谢。
能再举个例子吗?

比如这样两行code
a=2
b=a*2
c=b*2
if a>b:
print ".."
else:
print "..."

print a,b,c

请问这个要怎么trace?

tracing就是一行一行的运行程序,类似debug

做tracing的题,就是说明一个程序的每一个部分,
每一行程序是做什么用的

example:
a=2 #assign a value 2 to varible a
b=a*2 #assign the product of a and 2 to varible b
c=b*2 #assign the product of b and 2 to varible c
if a>b: #if a greater than b
print ".." #output ".."
else: #if not
print "..." #output "..."

print a,b,c #output the value of a,b,and c

我是昆仑_剑仙,分给昆仑_剑仙就好了

a=2 #assign a value 2 to varible a
b=a*2 #assign the product of a and 2 to varible b
c=b*2 #assign the product of b and 2 to varible c
if a>b: #if a greater than b
print ".." #output ".."
else: #if not
print "..." #output "..."

print a,b,c #output the value of a,b,and c