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

does anyone know the answer to this
a positive integer + a negative integer, when the negative integer is farther from 0
What are the 3 parts of a portfolio? Question 3 options: development, assignment, showcase decision, assignment, solution decision, assessment, solution develop
Some one help please
Each side of the cube is 8cm and the mass of the cube is 1,536g. What is the density of the cube?
What are some of the advantages and disadvantages of instituting some kind of order, rules, or leaders?​
plz do all correct for brainiest
A pop up blocker is a web browser feature that?
help me with exercise 1
Using a scale extending from -5 to 5 on both axes, plot and then join the points listed below. (2,4), (4,1), (2 - 2), (-2,-2), (-4,1),(-2, 4), (2, 4) The points