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

HELP 10 POINTS!!!! The letters Paul wrote fall into _______ categories. three four two
Who was the 1st to try to start a colony in North Carolina?
A leak in a pool causes the height of the water to decrease by 0.25 ft before the leak is fixed. After the leak is fixed the height of the water is 4.75 feet. T
Which of the following statements best explains why cities are so densely populated? A. Cities have good airports for traveling. B. Farms are the most densely p
If (-3, y) lies on the graph of y = (1/2)^x, then y =
American society is based on the caste system. T or F
which word pair from list 2 best completes the following anology: Investigate;examine:: options; report:describe reflect:analyze speculate:review elaborate:c
What is the value of x? Enter your answer in the box. x =
Medieval Christian Europe essay
Imagine you're seated at a café in Barcelona, and chatting with a new Spanish friend. You are trying to tell him or her some of the things you often do. Write a