2013-10-28 53 views
-2
# 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 

'错误。运行代码时出错。检查你在同一行上的代码前面没有空格。'存储距离的Python代码

为什么这不起作用?

我想我可以做到这一点,print nanodistance = 0.2998

+0

打印nanodistance = speed_of_light/nano_per_sec不工作,要么但 nanodistance = speed_of_light/nano_per_sec –

+0

确保有在你的指令中没有前导空格,除非它们在函数定义中。 – Barranka

+0

这看起来像作业... – wflynny

回答

3

周围其他方式:

nanodistance = speed_of_light/nano_per_sec