Python program to add two numbers with examples
In this example, we will learn how to add two numbers in python
Example 1:-
#python program to add two numbers
a=10
b=15
c=a+b
print(c)
Output
25
Note:- In this example, we have given value 10 to variable a, and value 15 to variable b, and just ADD them and display output using the print function.
Example 2:-
a=10
b=15
c=a+b
print(“a=”,a)
print(“b=”,b)
print(“addition of a and b= “,c)
Output
a=10
b=15
addition of a and b= 25
Note:- In this example, we are arranging the output of the program by showing the values of all variables.
Example 3:-
a=int(input(“enter first number: “))
b=int(input(“enter second number: “))
c=a+b
print(‘the sum of {0} and {1} is {2}’.format(a,b,c))
Output
enter first number: 10
enter second number: 15
the sum of 10 and 15 is 25
Note:- In this example, we asked the user to enter two numbers and then display the output in the formatted view.
Python Program to add two numbers
Python program to find Area of Square
Python program to find Area of Triangle
Python program to swap two variables
Python program to convert Celsius to Fahrenheit
Python program to generate Random Number
Python program to convert Miles to Kolometers
Python program to find Largest of 2 numbers
Python program to check if number is Odd or Even
Python program to check if number is Positive Negative or Zero
Python program to check Leap Year
Types of Loop in Python
Python program to check Prime Number
Python program to Calculate Sum of N Natural Numbers
Python program to find sum of All Even Number between 1 to 10
Python program to find sum of All Odd Number between 1 to 10
Python program to check Armstrong Number