#Program 1
'''Print
1 to 100 Odd Number'''
a = 1
while a<=100:
print(a,end='\t')
a+=2
############################################################
#Program
2
'''Program
to Print even numbers from 100 to 2 using while loop'''
a = 100
while a>0:
print(a,end='\t')
a-=2
#############################################################
#Program
3
'''Program
to Reverse a number'''
'''If
number is 4568 output should be 8654'''
n = int(input('Enter any number '))
m=n
#storing value of n in m
v = 0
while n>0:
r=n%10
v =
v * 10 + r
n = n // 10
print('Reverse of',m,'is',v)
#############################################################
#Program
4
'''Program
to check number is palindrome'''
'''Palindrome
number are those number whose reverse is same as original number'''
'''For
example 1221, 67876'''
n = int(input('Enter any number '))
m=n
#storing value of n in m
v = 0
while n>0:
r=n%10
v =
v * 10 + r
n = n // 10
if m == v: #comparing original and reverse
print('Its a Palindrome Number ')
else:
print('Its not a Palindrome Number ')
############################################################
#Program
5
'''Program
to check number is armstrong or not'''
'''Armstrong
number whose sum of cube of individual number is same as number'''
'''For
example 153 = cubeof(1) + cubeof(5) + cube(3)'''
n = int(input('Enter any number '))
m=n
#storing value of n in m
v = 0
while n>0:
r=n%10
v =
v + (r**3)
n = n // 10
if m == v:
print('Its an Armstrong Number ')
else:
print('Its not an Armstrong Number ')
#############################################################
#Program
6
'''Program
to count occurrence of Digit in any number'''
'''If
the number is 12322 and digit is 2 then output should be 3 times'''
n = int(input('Enter any number '))
d = int(input('Enter digit to search
in above number '))
m = n
count = 0
while n>0:
r = n % 10
if r == d:
count+=1
n = n // 10
if count==0:
print(d,'not found in',m)
else:
print(d,'found',count,'times in',m)
#############################################################
#Program
7
'''Program
to print fibonacci series'''
'''e.g.
0 1 1 2 3 5 8 13 ....'''
a=0
b=1
n = int(input('Enter How many terms
to print :'))
print(a,b,end=' ')
x=1
while x<=n-2:
c=a+b
print(c,end=' ')
a=b
b=c
x+=1
#############################################################
No comments:
Post a Comment