Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

Python Program to find Last Digit in a Number

by suresh

In this article, we will show you, How to write a Python Program to find Last Digit in a Number with practical example.

Python Program to find Last Digit in a Number

This python program will allow a user to enter any integer value. Next, it is going to find the Last Digit of the user entered value.

# Python Program to find Last Digit in a Number

number = int(input("Please Enter any Number: "))

last_digit = number % 10

print("The Last Digit in a Given Number %d = %d" %(number, last_digit))

OUTPUT

Python Program to find Last Digit in a Number 1

Python Program to find Last Digit in a Number using Function

This program is same as above but this time we separated the logic and placed it in the separate function.

# Python Program to find Last Digit in a Number

def lastDigit(num):
    return num % 10

number = int(input("Please Enter any Number: "))

last_digit = lastDigit(number)

print("The Last Digit in a Given Number %d = %d" %(number, last_digit))

OUTPUT

Python Program to find Last Digit in a Number 2

Placed Under: Python, Python Examples

Stay in Touch!

Sign Up to receive Email updates on Latest Tutorials

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy