write a program to print sum of two numbers.
#python
Answers
Answered by
10
note this will work in python 2.7
#to calculate the sum of two no.
a = input("A = ")
b = input("B = ")
s = a+b
print s
#to calculate the sum of two no.
a = input("A = ")
b = input("B = ")
s = a+b
print s
Attachments:
Answered by
5
In python, to find the sum, we will use the '+' symbol. Before doing that, we will need to take inputs from the user and then add it. I will show this to you in this 3 different ways. the 1st one being the longest but easily understandable and the last one being the shortest, it is easily understandable too.
num1 = int(input('First number:'))
num2 = int(input('Second number:'))
sum = 0
sum = sum + num1
sum = sum + sum2
print(sum)
Second method:
num1 = int(input('First number:'))
num2 = int(input('Second number:'))
print(num1+num2)
Third method:
print(int(input('First number:'))+int(input('Second number')))
Similar questions