Dremendo Tag Line

Square of middle digit in Python

input() - Question 7

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

Q7) Write a program in Python to input a three digit number and find the square of its middle digit.

Program

print('Enter a three digit number')
n=int(input())
md=(n//10)%10
print('Square of middle digit={}'.format(md*md))

Output

Enter a three digit number
562
Square of middle digit=36
video-poster