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.
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))
True False True False True
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join