Python Program to find sum of two integer numbers
Program
a = int(input('Enter number for a: '))
b = int(input('Enter number for b: '))
sum = a + b
print('Sum = ', format(sum))
This program takes two numbers as input from the user, adds them, and displays the sum. This program is a simple demonstration of basic input, output, and arithmetic operations in Python.
a = int(input('Enter number for a: '))
b = int(input('Enter number for b: '))
input()function is used to take user input.int()function converts the input from a string to an integer.- Two numbers (
aandb) are stored.
sum = a + b
- Addition operation is performed, storing the result in the
sumvariable.
print('Sum = ', format(sum))
- Prints the sum using the
format(sum)function.
Key Takeaways:
input()is used to take user input.int()converts string input to an integer.- Arithmetic operation (
+) is performed to find the sum. format()is used to format and display the result.
Output 1
Enter number for a: 5.6
Enter number for b: 9.12
Sum = 14.72
Output 2
Enter number for a: 4
Enter number for b: 81
Sum = 85