Practical Assignment
Practical Assignment
def Table():
print("Height(in feet)","\t","Height(in inches)")
f=5.0
while f<=6.0:
i=f*12
print(round(f,1),"\t","\t","\t",round(i,1))
f+=0.1
Table()
7. Write a program to print the series and its sum: (use functions)
1/1! + 1/2! + 1/3!.......I/n!
z=[]
def get_sum(n):
x=1
y=0
for i in range(1,n+1):
global z
z.append(1/i)
x=x*i
y=y+(1/x)
return y
print(get_sum(int(input("Enter any number: "))))
print(z)
b. n=int(input("Enter the number you want to check for perfect number: "))
def perf(p):
f=[]
s=0
for i in range(1,n):
if n%i==0:
f.append(i)
for j in f:
s+=j
if s==n:
print("It is a perfect number.")
else:
print("It is not a perfect number.")
perf(n)
c. n=int(input("Enter any number you want to check for armstrong number: "))
s=0
a=str(n)
for i in a:
b=int(i)
s+=b**3
if s==n:
print("Yes, it is an armstrong number")
else:
print("No, it is not an armstrong number")
g. str=input("Enter: ")
vowels=["a","e","i","o","u"]
v=0
c=0
for i in str:
if i in vowels:
v+=1
elif i==" ":
continue
else:
c+=1
print("The number of vowels in the provided string are ",v)
print("The number of consonants in the provided string are ",c)