Articles

Python program to add two numbers

Python program to add two numbers


In this python programs guide, we will learn to write:

  • python program to add two numbers

Program to find sum of two numbers in Python

Given below is a python program to add two numbers:

# Owner : TutorialsInhand Author : Devjeet Roy

n1 = int(input("Enter first number: "))
n2 = int(input("Enter second number: "))

addition = n1 + n2

print("The sum is:",addition)

The output is:

 

PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Enter first number: 34
Enter second number: 23
The sum is: 57

Few important points about this program:

1. In this program, we have taken two user inputs and converted them to their respective int data type. Thereafter we have found out its sum.

2. Even without using the "additon" variable, we can directly find the sum inside the print function by specifying n1 + n2 in place of "addition".

 

See the code snapshot for program to add two numbers in python

 

program to add two numbers in python

 


Basic Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Devjeet Roy
Full Stack Web Developer & Data Science Enthusiast
Page Views :    Published Date : Jan 20,2021  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!