存储距离的Python代码

时间:2013-10-28 20:24:07

标签: python

# Write Python code that stores the distance 
# in meters that light travels in one 
# nanosecond in the variable, nanodistance. 

# These variables are defined for you:

    speed_of_light = 299800000. # meters per second
    nano_per_sec = 1000000000. # 1 billion

# After your code,running
# print nanodistance
# should output 0.2998

# Note that nanodistance must be a decimal number.

# ASSIGN nanodistance BELOW this line
------------------------------------------

    speed_of_light/nano_per_sec = nanodistance

    print nanodistance

“不正确的。运行代码时出错。检查代码前面的同一行没有空格。

为什么这不起作用?

我想我可以通过print nanodistance = 0.2998

来做到这一点

1 个答案:

答案 0 :(得分:3)

其他方式:

nanodistance = speed_of_light / nano_per_sec