Exercise 200
Write an algorithm as python function which takes as parameters an integer n and which returns the last digit of n.
Solution
def lastDijit(n):
# The last digit is exactly the remainder of the Euclidean division of n by 10
lastDj = n%10
return lastDj
# Testing algorithm
print("The last dijit of 26783 is : " , lastDijit(26783))
Younes Derfoufi
my-courses.net
my-courses.net