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 theme is found in both “We Wear the Mask” and "A Man Said to the Universe"? All individuals must search to discover their places in the world. Each person
Write a rule for the linear function.
Ari Makes leather Wallets. She Makes 14 Every Three Weeks. How Many can She Make In 12 Weeks ?
when h has the value 5 calculate 6h+9
School uniforms can help students from feeling like they cannot keep up. Some students come to school in jeans that cost $200. Yet, twenty-five percent of the s
Which word describes best the voice of the excerpt from The Absolutely True Diary of a Part-Time Indian?
You can probably use the 1040EZ form, as long as what is true? A. You own your own business. B. You are paying estimated tax. C. You have at least two dependent
What's five different ways you can build a box that has a volume of 248 cubic inches
Which of the following situations is an example of specialization of labor? A.Three truck drivers communicate by radio about their routes. B.Three fieldworker
Find the percent change from the first value to the second.