kevinbaldridge9902 kevinbaldridge9902
  • 12-11-2020
  • Computers and Technology
contestada

Write a function named last_digit that returns the last digit of an integer. For example, last_digit(3572) should return 2. It should work for negative numbers as well; last_digit(-947) should return 7.

Respuesta :

Cytokine
Cytokine Cytokine
  • 12-11-2020

def last_digit(num):

   num = str(num)

   return int(num[-1])

print(last_digit(-947))

I hope this helps!

Answer Link

Otras preguntas

A  5 gallon mixture contains 40% acid. A 3 gallon mixture contains 50% acid. What percent is obtained by putting the two mixtures together?
What word means able to work properly while using less energy
What is the highest mountain in the United States and where is it located in the West region?
Where did strep throat originate? *PLEASE HELP!* PROJECT FOR SCIENCE!
what tools did scribes use in egypt
"Solving Equations by Completing the Square: m^2+2m-48=-6
What is square root of 270
"Solving Equations by Completing the Square: m^2+2m-48=-6
If n is even, which of the following cannot be odd? a) n + 3 b) 3n c) n² - 1, Can you please explain with some details?
Compare and contrast Germany's actions in the Rhineland, Austria, and Czechoslovakia