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 part or parts of the paragraph indicate that oxygen is important to life? Oxygen is the most abundant element on Earth. As the largest component of most
(3a)^3 without exponents
use dred and dye and make a sentence
What is the coefficient of y in the expression 3 ⋅ 4 + 5y?
Is "money will evaporate into thin air" -n example of metaphor, personification, hyperbole or any thing else?
A loop circuit has a resistance of R1 and a current of 2.2 A. The current is reduced to 1.4 A when an additional 3.1 Ω resistor is added in series with R1. What
What is the missing constant term in the perfect square that starts with x^2+10x?​
Balancing Chemical Equations. 1. ____ CaS +____ H2O ----> ____ Ca(HS)^2 + ____ Ca(OH)^2 2. ____ Au^2S^3 + _____ H2 ----> _____ Au + ____ H2S
d2 - 9k + for d = 10 and k = 9
For the following equations, find the ratio of a to b. Be sure to show all of your work. 3a=6b 15a=5b