0% found this document useful (0 votes)
8 views

Python Interview Prog

The document defines Python functions to check properties of numbers including whether they are strong, Armstrong, perfect, anagrams, panagrams, palindromes, Fibonacci sequences, prime, happy, spy or xylem/phloem numbers.

Uploaded by

Om Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Python Interview Prog

The document defines Python functions to check properties of numbers including whether they are strong, Armstrong, perfect, anagrams, panagrams, palindromes, Fibonacci sequences, prime, happy, spy or xylem/phloem numbers.

Uploaded by

Om Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

# 1) STRONG NUMBER

# ----checking strong number or not


# def is_strong(n):
# sum = 0
# for i in str(n):
# fact = 1
# for j in range(1,int(i)+1):
# fact *= j
# sum += fact
# if sum==n:
# return 'strong number'
# else:
# return 'not strong'
# print(is_strong(int(input())))

# 2 ) armstrong number
# # ----checking armstrong or not
# def is_armstrong(n):
# temp = n
# sum = 0
# while n>0:
# ld = n%10
# sum += ld**len(str(temp))
# n//=10
# if sum==temp:
# return 'Armstrong'
# else:
# return 'not armstrong'
# print(is_armstrong(int(input())))

# # 3) Perfect number
# # ------checking perfect number or not
# def is_perfect(n):
# sum = 0
# for i in range(1,n+1):
# if n%i == 0 and i!=n:
# sum+=i
# if sum==n:
# return 'perfect'
# else:
# return 'not perfect'
# print(is_perfect(int(input())))

# 4) anagram
# def is_anagram(s1,s2):
# if len(s1) == len(s2):
# for i in s1:
# if i in s2 and s1.count(i) == s2.count(i):
# continue
# else:
# print('Not Anagram')
# break
#
# else:
# print('Anagram')
# else:
# print('Not Anagram')
#
# is_anagram(input().upper(),input().upper())
#
#
# 5) panagram number
#
# def is_panagram(s):
# i =0
# out = set()
# if len(s)<26:
# print('Not a Panagram')
# else:
# while i<len(s):
# if 'a'<=s[i]<='z' or 'A'<=s[i]<='Z':
# if 'a'<=s[i]<='z':
# out.add(chr(ord(s[i])-32))
# else:
# out.add(s[i])
# i+=1
# if len(out) == 26:
# print('Panagram')
# else:
# print('not a panagram')
# is_panagram('A Quick $ 238472384723847230 Brown fox jumps
over The lazy Dog')

# 6) PALINDROME number
# def is_palindrome(n):
# org = n
# rev = ''
# while n>0:
# ld = n%10
# rev += str(ld)
# n//=10
# if org == int(rev):
# return 'palindrome'
# else:
# return 'not a palindrome'
# print(is_palindrome(int(input())))

#7) fibunacci sequence


# def fib(n):
# a=0
# b=1
# print(a,b,end=' ')
# for i in range(1,n+1):
# c=a+b
# print(c,end=' ')
# a=b
# b=c
# fib(int(input()))

# 8) PRIME NUMBER
# def is_prime(n):
# for i in range(2,n):
# if n%i == 0:
# return 'not prime'
# break
# else:
# return 'prime'
# print(is_prime(int(input())))

# 9) HAPPY NUMBER
# def is_happy(n):
# while True:
# sum = 0
# for i in str(n):
# sum += int(i)**2
# if sum == 1:
# return 'Happy number'
# break
# elif sum == 4:
# return 'not Happy'
# break
# n = sum
# print(is_happy(int(input())))

#10) spy number


# def is_spy(n):
# sum=0
# prod=1
# for i in str(n):
# sum+=int(i)
# prod*=int(i)
# if sum==prod:
# return 'SPY NUM'
# else:
# return 'Not a spy'
# print(is_spy(int(input())))

#11) Xylem and phloem number

# def is_xylem(n):
# sum1=int(str(n)[0])+int(str(n)[-1])
# print(sum1)
# sum2=0
# for i in range(1,len(str(n))-1):
# sum2+=int(str(n)[i])
# print(sum2)
# if sum1==sum2:
# return 'XYLEM'
# else:
# return 'PHLOEM'
# print(is_xylem(int(input())))

You might also like