Here, we will figure out how to discover the entirety of two numbers in Python? we input two numbers and will discover their sum.
Given two integer numbers and we need to discover their entirety in Python.
In the given underneath model, we have two factors num1 and num2 and doling out them with the worth 10 and 20, finding and printing the whole of the numbers. Later we are contributing two numbers from the info and relegating them num1 and num2.
Note: While contributing numbers from utilizing input() work, we get string esteem, to change over string an incentive to integer esteem – we have to change over them into an integer. To change over the string to an integer, use int() work.
ASCII estimation of character in Python
In python, to get an ASCII code of a character, we use ord() work. ord() acknowledges a character and returns the ASCII estimation of it.
Model code:
num1 = input("Enter first number: ")
num2 = input("Enter second number: ")
sum = int(num1) + int(num2)
Example:
Input:
num1 = 10
num2 = 20
Finding sum:
sum = num1 + num2
Output:
30
Python code to get a sum of two numbers:
# python program to find sum of
# two numbers
num1 = 10
num2 = 20
# finding sum
sum = num1 + num2
# printing sum
print("sum of ", num1, " and ", num2, " is = ", sum)
# taking input from user
num1 = input("Enter first number: ")
num2 = input("Enter second number: ")
# finding sum
sum = int(num1) + int(num2)
# printing sum
print("sum of ", num1, " and ", num2, " is = ", sum)
Output:
sum of 10 and 20 is = 30
Enter first number: 100
Enter second number: 200
sum of 100 and 200 is = 300