Problem Set 6(Eve Number)

A number ‘n’ is said to be an Eve number if the reverse of the square of the number ‘n’ is   not the square of the reverse of  ‘n’. For example, 15 is an Eve number.
Square of 15 = 225
Reverse of 15 = 51
Square of 51= 2601 which is not the reverse of square of 15
Write an Algorithm and the subsequent Python code to check whether the given number  is an Eve number or not.
Write a function to reverse a number
Input Format:
The first line will contain the number.
Output Format:
Print Eve number or Not an Eve number
Input:
the number

Processing Involved:
def reverse(n):
    return int(str(n)[::-1])

Output:
display if the number is a eve number or not

Program:
def reverse(n):
    return int(str(abs(n))[::-1])

n = int(input())
if n **2 != reverse(n)**2:
    print('Eve number')
else:
    print('Not an eve number')

Algorithm:
Step1. define the function reverse with one parameter n
Step1.1 return the reverse of the number using string operations
Step2. get the number n
Step3. check if the square of n is not equal to the square of the reverse of n
Step4. End

No comments:

Post a Comment

Bonus Practice Problems(GMT To IST)

IST (Indian Standard Time) is 5 hours 30 minutes ahead of GMT(Greenwich Mean Time). Develop an algorithm and write the Python code to find...