使用Python打印语句返回语法错误

问题描述 投票:-2回答:1

当我偶然发现这个问题时,我正在做一个简单的物理实验室。我的结论声明拒绝打印完成的值,以至于print(“ hello world”)甚至无法正常工作。

我正在google colab文档上运行此文档,这是作业要求的格式。

g = 9.8

velocity = input("Your Initial velocity is (m/s): ", float())

time = (velocity / (-1.0*g) )

d = ((velocity * time) + (0.5*g*(time**2))

print("Your maximum height is: ", d)
File "<ipython-input-18-04687c2e6c83>", line 33
    print("Your maximum height is: ", d)
        ^
SyntaxError: invalid syntax

这就是错误。我期望有一个浮点值。

python syntax syntax-error
1个回答
0
投票

d =((速度*时间)+(0.5 * g *(时间** 2))

缺少一个)

应该是:

d = ((velocity * time) + (0.5*g*(time**2)))
© www.soinside.com 2019 - 2024. All rights reserved.