2013-10-07 25 views
0
def main(): 
    result1=cubeVolume(2) 
    result2=cubeVolume(10) 
    print("side length 2 equals",result1) 
    print("side legnth 10 equals",result2) 
def cubVolume(sidelength): 
    volume = sideLength**3 
    return volume 
main() 

我是否正确地说在下面的顺序线中执行?程序按线路执行的方式

9,1,2,6,7,8,3,4,5

回答

0

行号执行如下:

1,6,9, 
    1,2, 
     6,7,8, 
    3, 
     6,7,8, 
    4,5 

6,7,8是你cubVolume功能。这个函数应该是cubeVolume(或者pythonicly cube_volume)。编辑:我已经把1,6,9,以表明正在注册的功能正如注册建议的戳。

+0

感谢您的澄清,我最终在发布之前更改了我的答案。 – Jake

+0

我会在开头稍微修改它为'1,6,9,...',因为文件最初是从上到下解释的,并且每个函数定义都会先执行以注册函数的名称。 – poke