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

Which development led to the other three? (1) growth of new home construction (2) increase in school populations (3) start of the baby boom (4) pre
May 13, 1958 The President The White House Washington, D. C.
Why were Americans encouraged by the outcome of the War of 1812?
Is GDP a good measure of the prosperity of the average person?
Which development led to the other three? (1) growth of new home construction (2) increase in school populations (3) start of the baby boom (4) pre
why did Louis XVI call a meeting to his estates general in 1789
Imagine that water is leaking from a container, at a rate of 1.2 ml/hour.  If this rate does not change, how many liters of water will be lost in a week
Which development most clearly illustrates the nativist attitudes that existed in the United States in the 192os? (1) limits on immigration establishe
The track coach notices that his star runner is running quicker than ever before, but quickly gets tired and shows evidence of depression after the race. The co
How did kristallnacht demonstrate Nazi persecution of Jews?