无法在Python中打印到屏幕没有产生错误

2024-04-20 16:10:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python初学者。我创建了这个简单的程序,但不会显示任何错误消息,也不会工作。输入后停止工作。我做错什么了?[Python 3.2]

import math

print('''

   |.
   |  .
  a|    . c
   |      .
   |________.
       b

''')

def robot():
    a = float(input('Enter side a, 0 for unknown \n: '))
    b = float(input('Enter side b, 0 for unknown \n: '))
    c = float(input('Enter hypotenuse c, 0 for unknown \n: '))

    if a == 0:
        print = ('a = ', (math.sqrt((c**2)-(b**2))))
    if b == 0:
        print = ('b = ', (math.sqrt((c**2)-(a**2))))
    if c == 0:
        print = ('a = ', (math.sqrt((a**2)+(b**2))))

    input()
    robot()


robot()

谢谢


Tags: 程序消息forinputif错误robotmath
1条回答
网友
1楼 · 发布于 2024-04-20 16:10:23
print = ('b = ', (math.sqrt((c**2)-(a**2))))
      ^

删除print后面的赋值运算符。print是一个函数,因此要调用它,只需在括号中提供参数,如下所示:

^{pr2}$

相关问题 更多 >