Python Program to Add Two Numbers

Python Programming Examples


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.

Program:

#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

Notifications

Updates are enabled for this browser.

Receive new tutorials, articles and learning resources. You can turn updates off anytime.

Test browser code

Use this code in admin to send a test notification to this browser.