Question

5-5. Same last digit Define a function that takes in three numbers and returns True if...

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

Homework Answers

Answer #1

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)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
For Cpp Write the definition of a function that takes as input the three numbers. The...
For Cpp Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the power of the second number equals the third number; otherwise, it returns false. (Assume that the three numbers are of type double).
Define a function in Scheme which takes a list of numbers and a scalar and returns...
Define a function in Scheme which takes a list of numbers and a scalar and returns the rest of the list after the first occurrence of the scalar that was passed. An empty list should be returned if the value doesn't exist. For example, (list-past-scalar '(5 2 8 3 1 9 2 3) 3) #returns (1 9 2 3) (list-past-scalar '(37 18 38 65 90) 100) #returns ()
Write a largestBelowValue(numbers, value) function that returns the largest number in the list numbers that is...
Write a largestBelowValue(numbers, value) function that returns the largest number in the list numbers that is smaller than value. Assume the numbers are always positive integers. Some example test cases (include these test cases in your program): >>>print(largestBelowValue([31, 5, 71, 53, 40, 17], 40)) 31 >>>print(largestBelowValue([31, 5, 71, 53, 40, 17], 41)) 40 returns None since no value is smaller than 2 in the list >>>print(largestBelowValue([31, 5, 71, 53, 40, 17], 2)) None
Create a function that takes two numbers as arguments (num, length) and returns an array of...
Create a function that takes two numbers as arguments (num, length) and returns an array of multiples of num up to length. Examples: arrayOfMultiples(7, 5) ➞ [7, 14, 21, 28, 35] arrayOfMultiples(12, 10) ➞ [12, 24, 36, 48, 60, 72, 84, 96, 108, 120] arrayOfMultiples(17, 6) ➞ [17, 34, 51, 68, 85, 102] Notes Notice that num is also included in the returned array. Write in C++ language ..
Python Implement function allEven() that takes a list of integers and returns True if all integers...
Python Implement function allEven() that takes a list of integers and returns True if all integers in the list are even, and False otherwise. >>> allEven([8, 0, -2, 4, -6, 10]) True >>> allEven([8, 0, -1, 4, -6, 10]) False
Using nested loops, write a function called primes(a,b) that takes in two positive integers a and...
Using nested loops, write a function called primes(a,b) that takes in two positive integers a and b (where a<b). Then simply RETURNS a string containing all the prime numbers between a and b (or if there are none, the string "No Primes"). You should check that a and b are valid inputs, that is, that a and b are integers such that a<b (otherwise, the function should print “No Primes”). Three sample calls of your function (in IDLE) should produce...
Write a C++ program that asks the user to enter in three numbers and displays the...
Write a C++ program that asks the user to enter in three numbers and displays the numbers in ascending order. If the three numbers are all the same the program should tell the user that all the numbers are equal and exits the program. Be sure to think about all the possible cases of three numbers. Be sure to test all possible paths. Sample Runs: NOTE: not all possible runs are shown below. Sample Run 1 Welcome to the order...
1.Write a function which takes in a dictionary are returns the sum of the keys plus...
1.Write a function which takes in a dictionary are returns the sum of the keys plus the sum of the values, but only if all the keys and all the values are integers. Otherwise it returns False. >>>f({'a':1,'b':4,'c':7,'d':11}) False >>>f({1:2,3:4,5:6,7:8}) 36 2.Write a function to quickly compute the recaman sequence. 3. The Hofstadter Conway sequence is defined by a(1)=a(2)=1 and (for n>2 by) a(n)=a(a(n-1))+a(n-a(n-1)). Write a function to quickly compute this sequence. >>> [hc(i) for i in range(1,20)] [1, 1,...
This is an intro to Python question: #Write a function called linear() that takes two parameters...
This is an intro to Python question: #Write a function called linear() that takes two parameters #- a list of strings and a string. Write this function so #that it returns the first index at which the string is #found within the list if the string is found, or False if #it is not found. You do not need to worry about searching #for the search string inside the individual strings within #the list: for example, linear(["bobby", "fred"], "bob") #should...
***************PLEASE GIVE ANSWERS IN RACKET PROGRAMMING LANGUAGE ONLY****************** Write a recursive Racket function "update-if" that takes...
***************PLEASE GIVE ANSWERS IN RACKET PROGRAMMING LANGUAGE ONLY****************** Write a recursive Racket function "update-if" that takes two functions, f and g, and a list xs as parameters and evaluates to a list. f will be a function that takes one parameter and evaluates true or false. g will be a function that takes one parameter and evaluates to some output. The result of update-if should be a list of items such that if x is in xs and (f x)...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT