Python Add Two Numbers with Examples

Published on Apr 12, 2022

In this snippet, we will learn how to add two numbers and display it.

Add Two Numbers

num1 = 10
num2 = 20

the_sum = num1 + num2

print(the_sum)

Add Two Numbers With User Input

num1 = input('First number: ')
num2 = input('Second number: ')

the_sum = float(num1) + float(num2)

print('The sum of {0} and {1} is: {2}'.format(num1, num2, the_sum))

Use our online IDE to run Python code.