Program 13
Write a program to find maximum and minimum element in a
list. List is inserted by user.
Solution
l=[]
n=int(input("Enter A Number"))
for i in range(0,n+1):
num=int(input("enter number to insert"))
l.append(num)
print("Maximum=",max(l))
print("Minimum=",min(l))
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
Write a program to create a third dictionary from two
dictionaries having some common keys, in way so that the
values of common keys are added in the third dictionary.
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) Open database ‘Hospital’
(C) Create a table ‘Doctor’ with following structure:
FieldName Datatype Key
Doc_ID Char(4) Primary Key
Doc_Name Varchar(30)
Doc_Speciality Varchar(30)
Mobile Varchar(10)
Address Varchar(30)
Salary Integer
(D) Display the structure of table ‘Doctor’
(E) Add one more column DOJ with Date datatype.
(F) Insert the following record:
(D101,Dr.Vaibhav,ENT,987345321,Delhi,2010-02-12.)
(G) Change to datatype of column Doc_Name from Varchar(30) to
Varchar(10).
(H) Rename the column Mobile to Contact.
(I) Delete column Address.
(J) Delete table Doctor.
Program 2
A) Create table books with appropriate data type.
B) Insert record (‘K01’,’Black book(Java)’,’FIRST
PUBL’,600,’Computer’,60)-
C) Add a new column author-
D) Update author name ‘Y.Kanatkar’ for B_id ‘K01’.
E) Show books of FIRST PUBL –
F) To display the cost of all book published by ‘EPB’.
G) Depriciate the price of all books of EPB Publisher by10 %.
H) To display the Book_name , Price of book more than 24 Qty.
I) To show the details of book whose name ends with ‘e’.
J) To display all records in descending order by price.
Program 3
Create a below given Student Table
Roll_no Stu_Name Class Sections Marks
101 Rohit 10 A 412
102 Alok 10 A 526
103 Roohi 9 B 427
104 Alka 10 B 500
105 Rahul 9 A 226
a) Create a table with appropriate data types.
b) Description of table
c) Insert data in the student table
d) Display all data
e) Delete the details of a particular student in the above table.