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 compound from question 3 would be classified as “organic”? A) H2O b) CCl4 c) NaCl d) Mg3P2 e) N2O5 Why?
why did so many colonists remain loyal to british during the revolutionary war?
how did Gatsby die in the the great Gatsby?
What cultural trait links north africa and southwest asia? a. they share arab roots b. the climates are the same c. they were all under english rule d. they wer
A ___________ chain is a sequence of amino acids that is the foundation for the basic structure of a protein. a. polynomial b. polypeptide c. polysaccharide
What system includes the core, mantle, and crust of the Earth?
Which of the following could be a slant cross section of a right cone? a. sphere b. oval c. triangle d. circle
Pepsin, a common enzyme found in the stomach, is most active at pH values between 0.5 and 2.5. It works slowly between pH values of 2.6 and 3.4. Beyond a pH of
The safest and most popular type of mortgage loan has a fixed rate and is called a _____. balloon loan ARM traditional loan VA loan
Why do I need a flu shot every year, while many other vaccinations last years or even a lifetime?