Python Sum of Two Numbers: Simple Guide

To calculate the sum of two numbers, you can use the simple addition operator +. Here is an example code:

num1 = 10
num2 = 20

sum = num1 + num2

print("The sum of", num1, "and", num2, "is:", sum)

In this example, we define two variables num1 and num2, with values of 10 and 20 respectively. We then use the addition operator + to calculate their sum and assign the result to the variable sum. Finally, the result is printed using the print function.

bannerAds