Practical File Programs (Class11)
Practical File Programs (Class11)
Output
Program 14
Write a program to print the frequency of the number from
a list if no not in a list then print no not found.
Solution:
count=0
l=[]
n=int(input("enter limit"))
for i in range(0,n):
num=int(input("enter no to insert list"))
l.append(num)
ser=int(input("enter number"))
for i in range(0,n):
if l[i]==ser:
count=count+1
if(count==0):
print("no not find")
else:
print("frequency=",count)
Output
Program 15
Write a program to input a list of n integers and find their
median.
Solution:
val=eval(input("Enter a list:"))
val.sort()
s=len(val)
mid=s//2
if s%2==0:
m1,m2=mid-1,mid
med=(val[m1]+val[m2])/2
else:
med=val[mid]
print("Median of given list is : ",med)
Output
Program 16
Write a code to calculate and display total marks and
percentage of a student from the given list storing marks
of a student.
Solution
sum=0
l=[ ]
n=int(input("enter limit"))
for i in range(0,n):
num=int(input("enter no. to insert in a list"))
l.append (num)
for i in range(len(l)):
sum=sum+l[i]
avg=sum/len(l)
print("total marks=",sum)
print("average marks=",avg)
OUTPUT
Program 17
Write a program to find the number of occurences of each
vowel present in input string.
SOLUTION
word=input('Enter string')
vowels={'a','e','i','o','u'}
d={ }
for i in word:
if i in vowels:
d[i]=d.get(i,0)+1
for k,v in sorted (d.items( )):
print(k,"occured",v,"times")
OUTPUT
Program 18
WAP to create a dictionary with keys as first characters and
value as words starting with characters
Solution
s=input("enter string")
l=s.split()
d={}
for i in l:
if (i[0] not in d.keys()):
d[i[0]]=[]
d[i[0]].append(i)
else:
if i not in d[i[0]]:
d[i[0]].append(i)
for k,v in d.items():
print(k,":",v)
Output
Program 19
WAP to store students name and their percentage in dictionary,
delete particular student name from dictionary .Also display
dictionary after deletion.
Solution
d={}
ch=1
n=int(input ("Enter a no of enteries"))
while ch<=n:
name=input ("Enter Name")
per=int(input("Enter Percentage"))
d[name]=per
ch=ch+1
b=d.keys()
print(d)
ser=input("Enter Name for Deletion")
for i in b:
if i ==ser:
d.pop(i)
print("After Deletion=",d)
Output
Program 20
Solution
d1={'1':100,'2':200,'3':300}
d2={'1':300,'2':200,'5':400}
d3=dict(d1)
d3.update(d2)
for i,j in d1.items():
for x,y in d2.items():
if i==x:
d3[i]=(j+y)
print("The Resultant Dictionary : ")
print(d3)
Output
SQL Based Queries Program
Program 1
(A) Create Database ‘Hospital’
b) Description of table