【发布时间】:2018-09-22 00:55:30
【问题描述】:
您好,我对代码很陌生,我需要知道如何输出通过计算 |x+y| 获得的值其中 x 是浮点数,y 是整数,都是未知输入。我尝试了很多事情,但都无法成功,请帮助我。
这就是我现在所拥有的,但我知道这是非常错误的 :( 在大多数情况下,当我尝试事情时,我会收到错误 TypeError: unsupported operand type(s) for +: 'int' and 'str'
这是我最近的尝试:
x = int(input())
y = input()
w = (x + y)
print (abs(w))
【问题讨论】:
标签: python floating-point integer addition absolute-value