Python Foundation Classroom Series – 20/Aug/2021

Problem solving contd..

  • Exercise: Problem: Try to find if a number is pallendrome or not
  • Solution
function is_pallendrome (number)

temp_number = number
reverse = 0
until number != 0 
    remainder = number%10
    reverse = remainder + reverse * 10
    number = number // 10

if reverse == temp_number:
   print pallendrome
max = 99
min = 10
first = max
second = max
largest = 0
largest_first = 0
largest_second = 0
until first >= min:
    until second >= min:
        number = first * second
        if is_pallendrome number and number > largest then
            largest = number
            largest_first = first
            largest_second = seond
        second = second -1
    first = first - 1

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin