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 (a and b) are stored.
sum = a + b
  • Addition operation is performed, storing the result in the sum variable.
print('Sum = ', format(sum))
  • Prints the sum using the format(sum) function.

Key Takeaways:

  1. input() is used to take user input.
  2. int() converts string input to an integer.
  3. Arithmetic operation (+) is performed to find the sum.
  4. 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