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

Use long division to solve (4x^4-5x^3+2x^2-x+5) ÷ (x^2+x+1)
Hi, it would be a load of help if someone could explain the working for this question. Three bricklayers Maric, Hugh and Ethan are cladding a new home. If Maric
What is the best explanation of the main difference between a rock and a mineral? A) Minerals are organic; rocks are inorganic. B) Rocks are naturally occurri
A researcher is concerned that graduate students get less than the recommended 8 hours of sleep a night. She selects a random sample of 45 students at a local u
Write the point-slope form of an equation of the line through the points (6, -1) and (5, -7).
Can someone please professionally explain the math equation. (Not just answer the question) 12b + 12 ≥ 60 SOLVE the inequality. GRAPH the solution. Make sure t
The square ABCD is divided into eight equal parts. The shaded area is 25 cm². What is the area of the square ABCD​
The Spar and Madison square is south of Sauna stores. Kelly's house is northeast of Sauna stores. Kelly's house is west of the Spar and Save Madison square. If
While reading a scientific article, a class of fifth-grade students completed a series of Frayer models on unfamiliar vocabulary words they encountered. To comp
A. -2/9 B. -1/3 C. 1/3 D. 2/9