Dremendo Tag Line

Calculate sum and check last digit even or odd in Python

if else - Question 8

In this question, we will see how to input 2 numbers and check if the sum of their last digit is even or odd in Python programming using the if else statement. To know more about if else statement click on the if else statement lesson.

Q8) Write a program in Python to input 2 numbers and check if the sum of their last digit is even or odd.

Program

print('Enter 2 numbers')
a=int(input())
b=int(input())
s=(a%10)+(b%10)

if s%2==0:
    print('Sum of their last digit is even')
else:
    print('Sum of their last digit is odd')

Output

Enter 2 numbers
54
69
Sum of their last digit is odd
video-poster