w3resource

Python: Sum of the last digit of first number and the last digit of second number equal to the last digit of third number

Python Basic - 1: Exercise-108 with Solution

Write a Python program that takes three integers and checks whether the sum of the last digit of the first number and the last digit of the second number equals the last digit of the third number.

Sample Solution:

Python Code:

def check_last_digit(x, y, z):
  return str(x+z)[-1] == str(y)[-1]
print(check_last_digit(12, 26, 44))
print(check_last_digit(145, 122, 1010))
print(check_last_digit(0, 20, 40))
print(check_last_digit(1, 22, 40))
print(check_last_digit(145, 129, 104))

Sample Output:

True
False
True
False
True

Pictorial Presentation:

Python: Sum of the last digit of first number and  the last digit of second number  equal to the last digit of third number.
Python: Sum of the last digit of first number and  the last digit of second number  equal to the last digit of third number.

Flowchart:

Flowchart: Python - Sum of the last digit of first number and  the last digit of second number  equal to the last digit of third number.

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to check whether a given number is Oddish or Evenish.
Next: Write a Python program find the indices of all occurrences of a given item in a given list.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.