Python Add Two Numbers with Examples

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.


Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.