We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4a9319f commit ba6bc2bCopy full SHA for ba6bc2b
1 file changed
palindrome_and_armstrong_check.py
@@ -0,0 +1,22 @@
1
+def palindrome(inp):
2
+ if inp==inp[::-1]: #reverse the string and check
3
+ print("Yes, {} is palindrome ".format(inp))
4
+ else:
5
+ print("No, {} is not palindrome ".format(inp))
6
+
7
8
+def armstrong(number):
9
+ num=number
10
+ length=len(str(num))
11
+ total=0
12
+ while num>0:
13
+ temp=num%10
14
+ total=total+(temp**length) #powering each digit with length of number and adding
15
+ num=num//10
16
+ if total==number:
17
+ print("{} is Armstrong number".format(number) )
18
19
+ print("{} is not an Armstrong number".format(number) )
20
21
+palindrome('qwerewq')
22
+armstrong(407)
0 commit comments