Learn how to add two numbers in Python.
Use the +
operator to add two numbers:
In this example, the user must input two numbers. Then we print the sum by calculating (adding) the two numbers:
x = input("Type a number: ")
y = input("Type another number: ")
sum = int(x) + int(y)
print("The sum is: ", sum)
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!