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

Simplify. −3x3(−2x2+4x−3) −5x5+x4−6x3 6x5−12x4+9x3 −6x6−12x4+9x3 6x6−12x3+9
i need help.. can somebody help me?
How did the soviet union maintain control in the satellite nations?
Can someone please help me solve this
Given the parent function f(x) = 2x, which graph shows f(x) + 1?
WXYZ IS A RECTANGLE. What is ZX?
I need help in confused
Choose the correct simplification of (8x4y3)2. 16x6y5 64x8y6 64x6y5 16x8y6
In the Sumerian Hierarchy, who is on the same level as the merchants?
Why did Nixon have to pick a new Vice President?