;

Python Program to Print Palindrome Numbers from 1 to 100


Tutorialsrack 23/04/2020 Python

In this Python Program, we will learn how to print Palindrome Numbers from 1 to 100 or between a specific range.

What is Palindrome?

A palindrome is a word, number, phrase, or other sequences of characters that reads the same backward as forward, such as civic or rotator or the number 14241. 

A number is a palindrome when we reverse the number and the reversed number is equal to the original number.

Here is the code of the program to print Palindrome Numbers from 1 to 100 or between a specific range.

Python Program to print Palindrome numbers from 1 to 100
# Python Program to print Palindrome numbers from 1 to 100

# Take the Input from the User
minValue = int(input("Enter the Minimum Value : "))
maxValue = int(input("Enter the Maximum Value : "))

print("Palindrome Numbers between %d and %d are : " %(minValue, maxValue))
for num in range(minValue, maxValue + 1):
    temp = num
    reverse = 0
    
    while(temp > 0):
        Reminder = temp % 10
        reverse = (reverse * 10) + Reminder
        temp = temp //10

    if(num == reverse):
        print("%d " %num, end = '  ')
Output

Enter the Minimum Value : 1

Enter the Maximum Value : 100

Palindrome Numbers between 1 and 100 are : 

1   2   3   4   5   6   7   8   9   11   22   33   44   55   66   77   88   99   


Related Posts



Comments

Recent Posts
Tags