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 video tutorial

Program to find sum of two numbers in Python

Here we are going to write python program to add two numbers

  • First we will accept two int variables n1 & n2.
  • After that we will perform addition of two numbers and 
  • finally print the sum as output.

Please check our video tutorial on program to add 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 of python program to add two numbers 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 & Blockchain Enthusiast
Page Views :    Published Date : Nov 06,2022  
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!