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

. Increasing the pressure on a gas __________ the volume the gas occupies. (Points : 1) increases decreases has no effect on
Conservatives who did not like the moral changes in society were known as preachers. True False
What happened in Manchuria in 1931
food couldn't reach the stomach without the esophagus and the what
Which important event held in Atlanta, Georgia, in 1996 had lasting impact on the culture and economy of Atlanta? the Three Governors Affair the Summer Olympic
Type of democracy where citizens are involved in day-to-day government
how much oxygen would be produced by heating 20 g of mercury (II) oxide if 18.6 g of mercury is produced?
The law of conservation of mass applies to all chemical reactions. True False
Which Athenian opened a school called the Academy? A. Plato B. Socrates C. Euripides D. Aristotle
Which sentence does not contain any errors in comma usage? A. We typically spend holidays at home but this Thanksgiving we are going to my aunt's house. B. We t