如何在 Python 中添加两个数字
使用+运算符将两个数字相加:
使用用户输入添加两个数字
在此示例中,用户必须输入两个数字。然后我们通过计算(相加)这两个数字来打印总和:
例子
x = input("Type a number: ")
y = input("Type another number: ")
sum = int(x) + int(y)
print("The sum is: ", sum)
转载于:
https://www.w3schools.com/python/python_howto_add_two_numbers.asp
浙公网安备 33010602011771号