5-5. Same last digit
Define a function that takes in three numbers and returns True if they all have the same last digit.
Test code:
print ( same_last_digit (2, 142, 262))
print ( same_last_digit (333, 36, 43))
print ( same_last_digit (41, 1, 21))
Sample run:
True
False
True
first=input("enter the first number:\t")
second=input("enter the second number:\t")
third=input("enter the third number:\t")
def same_last_digit(first,second,third):
if (first%10==second%10==third%10): #first%10 gives the last digit
of number
return True
else:
return False
print same_last_digit(first,second,third)
Get Answers For Free
Most questions answered within 1 hours.