-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclasses.py
39 lines (26 loc) · 1.03 KB
/
classes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
## This will be the first line comment
import regex as re
## Insert a space under each cell for code readability
# Define a class to check a Palindrome number
## Reference: https://www.includehelp.com/python/program-to-check-palindrome-number-using-object-oriented-approach.aspx
class Check :
# Constructor
def __init__(self,number) :
self.num = number
# define a method for checking number is Palindrome or not
def isPalindrome(self) :
# copy num attribute to the temp local variable
temp = self.num
# initialise local variable result to zero
result = 0
# run the loop untill temp is not equal to zero
while(temp != 0) :
rem = temp % 10
result = result * 10 + rem
# integer division
temp //= 10
# check result equal to the num attribute or not
if self.num == result :
print(self.num,"is Palindrome")
else :
print(self.num,"is not Palindrome")