Python program to enter two numbers and find their sum
ADVERTISEMENTS
Python program to the sum of two integers
# Python program to the sum of two integers
print("Enter two integer values::\n")
p, q, r = int(input()), int(input()), 0
r = p + q
print("\nResult:: ", p, " + ", q, " = ", r)
Output:
Enter two integer values::
5
7
Result:: 5 + 7 = 12
Python program to the sum of two integers with minimum variables
# Python program to the sum of two integers with minimum variables
print("Enter two integer values::\n")
p, q = int(input()), int(input())
print("\nResult:: ", p, " + ", q, " = ", end="")
p = p + q
print(p)
Output:
Enter two integer values::
5
7
Result:: 5 + 7 = 12
Python program to the sum of two float values
# Python program to the sum of two float values
print("Enter two float values::\n")
p, q = float(input()), float(input())
print("\nResult:: ", p, " + ", q, " = ", end="")
p = p + q
print(p)
Output:
Enter two float values::
5.23
7.29
Result:: 5.23 + 7.29 = 12.52