33. Python Program to Check Middle digit of given 3 digit number is Equal to the Sum of Other Two digits or Not.
How does this program work?
- In this program you are going to learn about how to Check Middle digit of given 3 digit number is Equal to the Sum of Other Two digits or Not using Python.
- Here First we claculate Last digit, First digit and their Sum.
- After that By using Mathematical Calculations like logarithm then compare Sum and middle digit using if condition and display result.
Here is the code
a = int(input("Enter a three digit number: "))
n = a % 10
a = int(a / 10)
b = a % 10
a = int(a / 10)
if b == (n + a):
print("Middle digit is numerically equal to the sum of other two digits")
else:
print("Middle digit is not numerically equal to the sum of other two digits")