Computer Practical
Computer Practical
1
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
PROJECT:
The aim of the class project is to create something that is tangible and useful using Python
file handling/ Python-SQL connectivity. This should be done in groups of two to three
students and should be started by students at least 6 months before the submission
deadline. The aim here is to find a real world problem that is worthwhile to solve.
Students are encouraged to visit local businesses and ask them about the problems that
they are facing. For example, if a business is finding it hard to create invoices for filing
GST claims, then students can do a project that takes the raw data (list of transactions),
groups the transactions by category, accounts for the GST tax rates, and creates invoices
in the appropriate format. Students can be extremely creative here. They can use a wide
variety of Python libraries to create user friendly applications such as games, software for
their school, software for their disabled fellow students, and mobile applications, of course
to do some of these projects, some additional learning is required; this should be
encouraged. Students should know how to teach themselves.
The students should be sensitized to avoid plagiarism and violations of copyright issues while
working on projects. Teachers should take necessary measures for this.
2
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
INDEX
QUESTION
S.NO TITLE PAGE NO
NO
3
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
4
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
SOURCE CODE:
def sumfib(n):
s=0
f1=-1
f2=1
for i in range(n):
f3=f1+f2
print(f3,end="+")
s=s+f3
f1=f2
f2=f3
return s
def fact(n):
f=1
for i in range(1,n+1):
5
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
f=f*i
return f
c=1
while c:
if c==1:
x=int(input("Enter nth term"))
s=1
for i in range(1,x+1):
if i%2!=0:
s=s+i/fact(i)
else:
s=s-i/fact(i)
print("sum of the series =",s)
if c==2:
x=int(input("Enter nth term"))
y=sumfib(x)
6
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
print("=",y)
OUTPUT:
RESULT: THUS THE ABOVE PROGRAM IS EXECUTED AND OUTPUT IS VERIFIED SUCCESSFULLY
7
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
s=0
for i in range(100,1000):
s1=0
for j in range(1,i//2+1):
if i%j ==0:
s1=s1+j
if s1==i:
s=s+i
return s
c=1
while c:
print("1. To sum prime numbers up to n terms")
print("2. To sum Armstrong numbers")
print("3. To sum perfect numbers")
print("0. To Exit")
c=int(input("Enter your choice"))
if c==1:
x=int(input("Enter nth term"))
y=prime(x)
print(" sum =",y)
if c==2:
y=armstrong()
print("sum=",y)
if c==3:
y= perfect()
print("sum=",y)
OUTPUT:
RESULT: Thus the above program is executed and output is verified
successfully
9
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
SOURCE CODE:
def lsearch(l,e):
for i in range(len(l)):
if l[i]==e:
return i
else:
return -1
def bsearch(l,e):
lb=0
ub=len(l)-1
while lb<=ub:
mid =(lb+ub)//2
if e== l[mid]:
10
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
return mid
elif e >l[mid]:
lb=mid+1
else :
ub=mid-1
return -1
c=1
while c:
print("1. Search an Element using Linear search")
print("2. Search an Element using Binary search")
print("0. To Exit")
c=int(input("Enter your choice"))
if c==1:
l=eval(input("Enter the List"))
print("Content of List")
print(l)
x=int(input("Enter Element to search" ))
y=lsearch(l,x)
if y !=-1:
print( x,"Found at ",y,"Postion")
else:
print(x, "Not Found in the list")
11
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
if c==2:
x=eval(input("enter a list"))
x.sort()
print("original List")
print(x)
y=int(input("Enter element to search"))
r=bsearch(x,y)
if r==-1:
print(y, "Not found in the list")
else:
OUTPUT:
To write a python code using functions i) accept list and print original list ii) Sort
list in ascending order using bubble sort iii) sort list in descending order using
insertion sort.
SOURCE CODE:
l=[]
c=1
def bsort(l):
n=len(l)
for i in range(n):
for j in range(n-i-1):
if l[j]>l[j+1]:
l[j+1],l[j]=l[j],l[j+1]
return l
def isort(l):
for i in range(len(l)):
j=i-1
t=l[i]
13
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
c=1
while c:
print("1.Store data in the list")
print("2.Sort using Bubble sort")
print("3.Sort using insertion sort")
print("0. exit")
c=int(input("Enter your choice"))
if c==1:
l= eval(input("Enter the list"))
if c==2:
print("original List")
print(l)
l=bsort(l)
print("Sorted list")
print(l)
14
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
if c==3:
print("original List")
print(l)
l=isort(l)
print("Sorted list")
print(l)
OUTPUT:
15
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
16
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
SOURCE CODE:
def createfile():
f=open("text.txt","w")
n=int(input("enter Number of lines"))
for i in range(n):
x=input("Enter a line")
f.write(x+"\n")
f.close()
def readandcount():
f=open("text.txt","r")
x=f.readlines()
lc=len(x)
f.seek(0,0)
x=f.read()
x1=x.split()
17
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
wc=len(x1)
cc=len(x)
print("content of file")
print(x)
print("Line count :",lc)
print("Word count :",wc)
print("character count :",cc)
c=1
while c:
print("1.To create Text file")
print("2.To display file and display line,word, character count")
print("0 To Exit")
c=int(input("Enter your choice"))
if c==1:
createfile()
elif c==2:
readandcount()
OUTPUT:
18
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
19
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
To Write a python script i) to create text file ii) To display the file iii) to find
display all repeated words with their word count.
def createfile():
f=open("test.txt","w")
n=input("Enter a string")
f.write(n)
f.close()
def readfile():
d={}
f=open("test.txt","r")
x=f.read()
f.close()
print("Content of file")
print("======================")
print(x)
print("======================")
for i in x.split():
if i not in d:
20
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
d[i]=1
else:
d[i]=d[i]+1
print("Frequency of words")
print("======================")
for i in d:
print(i,'\t',d[i])
print("======================")
c=1
while c:
print("1.To Create Text file")
print("2.To Display file and Repeated words")
print("0. Exit ")
SOURCE CODE:
def createfile():
f=open("source.txt","w")
n=int(input("enter Number of lines"))
for i in range(n):
x=input("Enter a line")
f.write(x+"\n")
f.close()
def readfile():
f=open("source.txt","r")
x=f.readlines()
print("Content of source file")
print("======================")
for i in x:
print(i,end='')
f.close()
22
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
f1=open("target.txt","r")
x=f1.readlines()
print("Content of target file")
print("======================")
for i in x:
print(i,end='')
f1.close()
def writefile():
f=open("source.txt","r")
f1=open("target.txt","w")
x=f.readlines()
for i in x:
t=i.title()
f1.write(t)
f.close()
f1.close()
print("Target file created, press enter to continue...")
x=input()
c=1
23
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
while c:
print("1.To create Source file")
print("2.To create Target file")
print("3.To display files")
print("4.To Exit ")
c=int(input("Enter your choice"))
if c==1:
createfile()
elif c==2:
writefile()
elif c==3:
readfile()
elif c==4:
break
OUTPUT:
24
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
SOURCE CODE:
import csv
def createcsv():
f=open("telephone.csv","w",newline="")
mywriter=csv.writer(f,delimiter=',')
n=int(input("Enter number of records"))
for i in range(1,n+1):
rno = input(" Enter Roll Number")
name=input("Enter Name ")
tn=input("Enter Telephone Number")
row=[rno,name,tn]
mywriter.writerow(row)
f.close()
def readcsv():
25
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
f=open("telephone.csv","r")
ro=csv.reader(f)
print("==========================================")
print("%-10s"%"Rno","%-20s"%"Name","%-
10s"%"Telephone Number")
print("==========================================")
for i in ro:
print("%-10s"%i[0],"%-20s"%i[1],"%-10s"%i[2])
print("==========================================")
f.close()
def search(tn):
f=open("telephone.csv","r")
ro=csv.reader(f)
for i in ro:
if i[2]==tn:
print( "Roll No ------------:",i[0])
print("Name ------------:",i[1])
print("Telephone ------------:",i[2])
return True
return False
c=1
while c:
26
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
27
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
SOURCE CODE:
import csv
def createcsv():
f=open("student.csv","w",newline="")
mywriter=csv.writer(f,delimiter=',')
n=int(input("Enter number of records"))
for i in range(1,n+1):
rno = input(" Enter Roll Number")
name=input("Enter Name ")
mark=input("Enter Marks")
row=[rno,name,mark]
mywriter.writerow(row)
f.close()
def displaycsv():
f=open("student.csv","r")
ro=csv.reader(f)
print("==========================================")
print("%-10s"%"Rno","%-20s"%"Name","%-10s"%"Marks")
28
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
print("==========================================")
for i in ro:
print("%-10s"%i[0],"%-20s"%i[1],"%-10s"%i[2])
print("==========================================")
f.close()
def createpfcsv():
f=open("student.csv","r")
f1=open("pass.csv","w",newline="")
f2=open("fail.csv","w",newline="")
mywriter1=csv.writer(f1,delimiter=',')
mywriter2=csv.writer(f2,delimiter=',')
ro=csv.reader(f)
for i in ro:
row=[i[0],i[1],i[2]]
if int(i[2]) >=33:
mywriter1.writerow(row)
else:
mywriter2.writerow(row)
f.close()
f1.close()
f2.close()
29
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
def displaypffile():
f=open("pass.csv","r")
ro=csv.reader(f)
print("Passed Students")
print("=============")
print("==========================================")
print("%-10s"%"Rno","%-20s"%"Name","%-10s"%"Marks")
print("==========================================")
for i in ro:
print("%-10s"%i[0],"%-20s"%i[1],"%-10s"%i[2])
print("==========================================")
f.close()
f1=open("Fail.csv","r")
ro=csv.reader(f1)
print("Failed Students")
print("=============")
print("==========================================")
print("%-10s"%"Rno","%-20s"%"Name","%-10s"%"Marks")
print("==========================================")
for i in ro:
print("%-10s"%i[0],"%-20s"%i[1],"%-10s"%i[2])
print("==========================================")
30
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
f1.close()
c=1
while c:
print("1.To create csv file")
print("2.To Display Original File")
print("3.To Create Pass and Fail File")
print("4.Display Pass and Fail File")
print("5.To Exit ")
c=int(input("Enter your choice"))
if c==1:
createcsv()
elif c==2:
displaycsv()
elif c==3:
createpfcsv()
elif c==4:
displaypffile()
elif c==5:
break
OUTPUT:
31
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
32
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
To Write a program i) to create binary file stud.dat having rollno, name, marks
ii) Display content of file ii) to display data in descending order of marks
SOURCE CODE:
import pickle
def create():
f=open("stud.dat","ab")
n=int(input("Enter number of students"))
for i in range(n):
rno=int(input("Enter Roll No"))
name=input("Enter Name")
marks=int(input("enter Marks"))
rec=[rno,name,marks]
pickle.dump(rec,f)
f.close()
def displayfile():
f=open("stud.dat","rb")
while True:
33
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
try:
rec=pickle.load(f)
print("Roll No--------------------:", rec[0])
print("Name---------------------:",rec[1])
print("Marks---------------------:",rec[2])
except:
break
f.close()
def descending():
f=open("stud.dat","rb")
l=[]
while True:
try:
rec=pickle.load(f)
l.append(rec)
except:
break
f.close()
n=len(l)
print(l)
34
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
for i in range(len(l)):
for j in range(len(l)-i-1):
if l[j][2]<l[j+1][2]:
l[j+1],l[j]=l[j],l[j+1]
for i in range(n):
print("%-10s"%l[i][0],"%-30s"%l[i][1],"%-20s"%l[i][2])
print("==========================================")
#driver code
while True:
print("1. Create Binary File")
print("2. Display File Content")
print("3. Display File in descending Order of Marks")
c=int(input("enter your choice, 0 to exit"))
35
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
if c==1:
create()
if c==2:
displayfile()
if c==3:
descending()
if c==0:
break
OUTPUT:
36
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
SOURCE CODE:
import pickle
import os
def create():
f=open("emp.dat","wb")
n=int(input("Enter number of employees"))
for i in range(n):
eno=int(input("Enter Employee No"))
name=input("Enter Name")
sal=int(input("Enter salary"))
rec=[eno,name,sal]
pickle.dump(rec,f)
f.close()
def displayfile():
f=open("emp.dat","rb")
print("==========================================")
37
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
print("%-10s"%"Empno","%-20s"%"Name","%-10s"%"Salay")
print("==========================================")
while True:
try:
rec=pickle.load(f)
print("%-10s"%rec[0],"%-20s"%rec[1],"%-10s"%rec[2])
print("==========================================")
except:
break
f.close()
def updaterec():
f=open("emp.dat","rb")
en=int(input("Enter Employee number whose salary to update"))
l=[]
fo=0
while True:
try:
rec=pickle.load(f)
if rec[0]==en:
print("Emp No--------------------:", rec[0])
print("Name---------------------:",rec[1])
38
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
print("Salary---------------------:",rec[2])
rec[2]=int(input("New salary"))
fo=1
l.append(rec)
except:
break
f.close()
if fo==1:
f=open("emp.dat","wb")
for i in l:
pickle.dump(i,f)
else:
print(en, "Not Found")
x=input("Press Enter to continue....")
f.close()
#driver code
while True:
print("1. Create Binary File")
print("2. Update Salary of an employee")
print("3. Display File ")
c=int(input("enter your choice, 0 to exit"))
39
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
if c==1:
create()
if c==2:
updaterec()
if c==3:
displayfile()
if c==0:
break
OUTPUT:
40
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
SOURCE CODE:
import os
import pickle
def create():
f=open("School.dat","ab")
n=int(input("Enter number of Schools"))
for i in range(n):
afno=int(input("Enter Affiliation No"))
sname=input("Enter School Name")
reg=input("Enter Region")
rec=[afno,sname,reg]
pickle.dump(rec,f)
f.close()
def displayfile():
f=open("school.dat","rb")
print("============================================")
41
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
print("%-10s"%"Schoolno","%-20s"%"SchoolName","%-
10s"%"Region")
print("=============================================")
while True:
try:
rec=pickle.load(f)
print("%-10s"%rec[0],"%-20s"%rec[1],"%-10s"%rec[2])
print("=============================================")
except:
break
f.close()
def delrec():
f=open("school.dat","rb")
f1=open("temp.dat","wb")
l=[]
while True:
try:
rec=pickle.load(f)
print("School No------------------------:", rec[0])
print("Scholl Name---------------------:",rec[1])
print("Region-----------------------------:",rec[2])
ch=input("Like to Delete this record y/n")
42
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
if ch.lower()=='y':
continue
else:
pickle.dump(rec,f1)
except:
break
f.close()
f1.close()
os.remove("school.dat")
os.rename("temp.dat","school.dat")
#driver code
while True:
print("1. Create Binary File")
print("2. Delete Records")
print("3. Display File ")
c=int(input("enter your choice, 0 to exit"))
if c==1:
create()
if c==2:
delrec()
if c==3:
43
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
displayfile()
if c==0:
break
OUTPUT:
44
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
45
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
else:
print("Content of stack: ")
for i in range(len(l)):
print(l[i],end="->")
print()
while True:
print("1. Push Element into a Stack")
print("2. Pop Element from a Stack")
print("3. Peek Element from stack")
print("4. Display content of a stack")
print("5. Exit")
c=int(input("Enter your choice:"))
if c==1:
x=int(input("Enter element to push: "))
push_elt(l,x)
elif c==2:
pop_elt(l)
elif c==3:
peek(l)
elif c==4:
display(l)
46
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
elif c==5:
break
else:
print("Please enter the correct choice....")
OUTPUT:
47
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
AIM:
Write a program to implement a stack of book in a dictionary
{book no: book name}
Source code:
#Program to implement a stack of book details {book no: book
name}.
#
book=[]
def push_item(l,x):
l.append(x)
print("Element Inserted")
def pop_item(l):
if l==[]:
print("Underflow!! Stack is empty")
else:
print(l.pop(),"is removed from stack")
def peek(l):
if l==[]:
print("Stack is empty")
else:
48
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
for i in range(len(l)):
print(l[i],end="->")
print()
while True:
print("Stack operations for Book details")
print("-"*45)
print("1. Push book details")
print("2. Pop book details")
print("3. Peek book details")
print("4. Display book details")
print("5. Exit")
c=int(input("Enter your choice:"))
if c==1:
bno=int(input("Enter book no to be inserted: "))
49
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
OUTPUT:
50
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
51
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
52
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
print("*"*50)
for i in cur:
print (i[0]," "," ",i[1]," ",i[2],"\t",i[3],"\t\t",i[4])
print("*"*50)
#Displaying the structure of the table
def display_structure():
print("STRUCTURE OF THE TABLE")
print("="*40)
print()
cur.execute("describe student")
print("Field\t Type \t\t Null \t Key \t Default")
print("*"*50)
for i in cur:
print(i[0],"\t",i[1],"\t",i[2],"\t",i[3])
print("*"*50)
c=1
while c:
print("1. Insert rows into the table")
print("2. Display the contents of the table")
print("3. Display the structure of the table")
print("0. To Exit")
c=int(input("Enter your choice: "))
53
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
if c==1:
insert()
elif c==2:
display()
elif c==3:
display_structure()
elif c==0:
break
else:
print("Wrong choice. Connection closed.....")
cur.close()
con.close()
OUTPUT:
54
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
55
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
cur.execute("desc student")
for i in cur:
print(i)
print( "like to alter table Y/N")
ch=input()
if ch=="Y" or ch=="y":
cur.execute("Alter table student add column marks
decimal(6,2)")
c=1
else:
c=0
#update data in the rows
while c:
cl=input("Enter Class")
d=input("Enter division")
ma = int(input("Enter Marks"))
cur.execute("update student set marks = {} where class = '{}' and
section ='{}' ".format(ma,cl,d))
56
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
58
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
59
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
60
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
SOURCE CODE:
'''
Create database school
Create tables students and sports.
Insert data into tables.
Create a Python application to
i) Display the number of coaches for each game
ii) Display the admno, name, class, section, game and coach name
of the students
iii) Display the number of students in each class
iv) Display the names of coaches who have “ball” in their games
v) Display the details of the students whose address is NULL'''
61
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
62
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
OUTPUT:
63
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
(i) Display the Mobile company, Mobile name & price in descending
(ii) List the details of mobile whose name starts with “S”.
except “MB003‟.
64
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
(iv) To display the name of mobile company having price between 3000 &
5000.
MB004 450
MB003 400
MB003 300
MB003 200
65
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
2017-11-20 2010-08-21
AND M2.M_Qty>=300;
5450
66
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
theirHiredate.
ORDER BY HIREDATE;
ii. To display the TNAME and CITY of Trainer who joined the Institute in
AND ‘2001-12-31’;
67
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
tables TRAINER and COURSE of all those courses whose FEES is less than
or equal to 10000.
GROUP BY CITY;
‘MUMBAI’);
Ans.
103 DEEPTI
106 MANIPRABHA
Ans.
101
103
102
104
68
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
105
HAVING COUNT(*)>1;
Ans.
101 2 12000
‘2018-09-15’;
Ans.
4 65000
69
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
22 – SQL COMMANDS - 3
ii) To display the details of courses whose fees is in the range of 15000 to
iii ) To increase the fees of all courses by 500 of “System Design” Course.
70
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
Ans: 4
FACULTY.F_ID;
Ans: 6000
Ans: 60000
Ans: 17500
71
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
23 – SQL COMMANDS -4
i. To display all the details of those watches whose name ends with ‘Time’
ii. To display watch’s name and price of those watches which have price
72
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
iv. To display watch name and their quantity sold in first quarter.
1 15
2 30
3 45
4 15
w.watchid!=s.watchid;
group by s.watchid;
HighTime 100 25 75
73
PRACTICAL PROGRAMS WITH SOLUTION
COMPUTER SCIENCE - XII
(i) To display the records from table student in alphabetical order as per
order by name;
(ii ) To display Class, Dob and City whose marks is between 450 and 551.
(iii) To display Name, Class and total number of students who have
group by class
set marks=marks+20
where class=’XII’;
COUNT(*)>1;
2 Mumbai
2 Delhi
2 Moscow
08-12-1995 07-05-1993
Sanal F
Store M
-----xxx-----
75