Python Program to find difference of two integer numbers
Program
a = int(input('Enter number for a: '))
b = int(input('Enter number for b: '))
difference = a - b
print('Difference = ', format(difference))
This program inputs two numbers, calculates their difference, and prints the result. This simple program demonstrates basic input, output, and arithmetic operations in Python.
a = int(input('Enter number for a: '))
b = int(input('Enter number for b: '))
input()function takes user input as a string.int()function converts the input to an integer.- The user enters two numbers (
aandb).
difference = a - b
- Subtraction (
-) is performed, and the result is stored indifference.
print('Difference = ', format(difference))
- Prints the difference using the
format(difference)function.
Key Takeaways:
- User inputs two numbers.
- Conversion to integers using
int(). - Subtraction operation (
-) is performed. - Result is displayed using
format().
Output
Enter number for a: 56
Enter number for b: 12
Difference = 44