Python Programming Examples Tutorial Index

Python Number Programs

This Python example program demonstrates how to sum two numbers in Python using arithmetic operators. In this program, the value of two variables is defined first, then the value of the sum of these two variables is assigned to another variable, and then it is printed.


#Variable definition and assignment
num1 = 3.5
num2 = 1.5

#Add two numbers
sum = num1 + num2

#Print the output
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))

Program Output:

The sum of 3.5 and 1.5 is 5.0

Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram