Dremendo Tag Line

Product of first and last digit in Python

input() - Question 6

In this question, we will see how to input a three digit number in Python programming using the input() function and find the product of its first and last digit. To know more about input() function click on the input() function lesson.

Q6) Write a program in Python to input a three digit number and find the product of its first and last digit.

Program

print('Enter a three digit number')
n=int(input())
fd=n//100
ld=n%10
pr=fd*ld
print('First digit={}'.format(fd))
print('Last digit={}'.format(ld))
print('Product of first and last digit={}'.format(pr))

Output

Enter a three digit number
854
First digit=8
Last digit=4
Product of first and last digit=32
video-poster