Practicals 11
Practicals 11
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
# Python program to check whether the given number is a perfect number or not
for i in '10101':
print (i)
if (str2 == str1):
print("String is a palindrome")
else:
print("String is not a palindrome")
def fibonacci(n):
a=0
b=1
if n <= 0:
print("Incorrect input")
elif n == 1:
print (b)
else:
print (a)
print (b)
for i in range(2,n+1):
c=a+b
a=b
b=c
print (b, end= ' ')
while(True):
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1
return lcm
#Count and display the number of vowels, characters, digits, spaces in string
str = input('Enter the string : ')
vowels = 0
digits = 0
spaces = 0
ch=0
str = str.lower()
print("Vowels :",vowels)
print('Digits: ', digits);
print('White spaces: ', spaces);
print ("Characters :",ch)
#program that displays the longest substring of given string having just the consonsnts
string=input('Enter a string ' )
length=len(string)
maxlength= 0
maxsub ='' #empty string
sub=''# empty string
lensub=0
for a in range(length):
if string[a] in 'aeiou' or string[a] in 'AEIOU':
if lensub > maxlength:
maxsub = sub
maxlength= lensub
sub =''
lensub = 0
else:
sub += string[a]
lensub =len(sub)
a+=1
print ("Maximum length consonant substring is" , maxsub, end =' ')
print ("with", maxlength, "characters")
#Write a program that reads a string and then prints a string that capitalizes every other letter in the
string e.g,