Oswal Practice Papers CBSE Class 12 Computer Science Solutions (Practice Paper - 7)

Section-A 

1. True

Explanation :    

Default arguments to a function have to be assigned right to left.

2. (a) Like

Explanation :    

The Like clause can be used to match patterns in a string.

3. (b) 2402

Explanation :    

160%5 + 7**2**2 + 16//12 = 1 + 2401 + 1
= 2403

4. (a) 'Bombay is india’s trade centre'

Explanation :    

The capitalize() function makes the 1st letter of the sentence capital.

5. (d) Both a and b

Explanation :    

Candidate keys are the set of all keys , from which primary and alternate keys are derived.

6. (c) InfraRed

Explanation :    

Infra Red is a line of sight communication that uses infra red radiation for transmission.

7. (a) 1/3

Explanation :    

The code creates tuple, adds elements and prints their lengths.

8. (a) True

Explanation :    

p+q>r and not q or q%5==0
55> 26 and not 30 or 30%5==0
True and False or True
False or True
True

9. (b) F = open (‘People.txt’, ‘A’)

Explanation :    

Option b is invalid because ‘A’ is an invalid mode in Python.
‘w’ Opens a file for write mode.
‘a’ Opens a file for append mode
‘w+’ Opens a file for both writing and reading

10. (b) SOUTHNORTHWEST

Explanation :    

In the code random and randint function are used and for loop is used. So, we get the output
SOUTHNORTHWEST.

11. (c) commit()

Explanation :    

The commit() method saves the changes done by a transaction to a database permanently.

12. (c) str[-1] in “AEIOU”

Explanation :    

The last character in a string can be checked by index -1

13. (a) True

Explanation :    

There can be unusual situations in a program anytime.

14. (a) Unique

Explanation :    

The Unique constraint restricts duplicate values in a column.

15. (a) Star

Explanation :    

Since connections are independent in star topology , error detection is easy

16. (d) a

Explanation :    

The ‘a’ or append mode opens a file for adding more data keeping the previous data.

17. (d) A is false but R is True

Explanation :    

Indexing is used for accessing individual characters within a string. The first character has the index 0 and the last character has the index n-1 where n is the length of the string. The negative indexing ranges from -n to -1.
Strings in Python are immutable, i.e., a string cannot be changed after it is created.

18. (a) Both A and R are true and R is the correct explanation for A

Explanation :    

Illegal operations can raise exceptions. There are plenty of built-in exceptions in Python that are raised when corresponding errors occur. We can view all the built-in exceptions using the built-in local() function as follows:
print(dir(locals()['__builtins__']))

Section-B

19. (i) (a) TCP/IP : Transmission control protocol / Internet protocol
(b) CDMA : Code Division Multiple Access
(ii) The process of uploading web pages to a public server is called web hosting.

20. To=30 #Error1
for K in range(0,To):
if k%4==0: #Error2
print (K*4)
else: #Error3
print (K+3)

21. def ZeroEnding (SCORES): SZero = 0
for i in scores:
if 1 % 10 = =, O:
Szero += i
print(“Sum of numbers ending with zero:”, SZero)

OR

defbig(Str):
for s in Str:
if s[0] in “aeious” and s[–1] in “aeiou”:
print(s)

22. Hi
Hello
Namaste

23. (i) Empdict[“Email”]= [email protected]
(ii) print(Lstnames*5)

24. Create table toys(Toyld integer, Toynamevarchar(20) , Category varchar(1) , Price float(8,2), Vendor
varchar(20));
Describe toys;

25. [45, 67, 3]
2

Section-C

26. SCHOOLbbbbCOM

27. (i) Distinct TID
101
103
102
104
105

(ii) TID Count(*) MIN(FEES)
      101     2            12000

(iii) Count(*)  SUM FEES
         4               65000

28. def displayMeMy():
num=0
f=open("story.txt","r+")
N=f.read()
M=N.split()
for x in M:
if x.lower()=="me" or x.lower()== "my":
num=num+1
f.close()
print("Count of Me/My in file:",num)

OR

def countFirstDigit( )
counts=0
with open(‘Diary.txt’, ‘r’) as f:
while true:
line=f,readline( )
if not line:
break
if line[0], isdigit( ):
count = count+1
if count = =0:
print (“no line starts with a digit“)
else:
print (“count=”, count)

29. (a) Select count(distinct RNO) from Students;
(b) Select Name , Class, Address from students where name like “%EE%” order by Sec Desc;
(c) Update STUDENTS Set Address=”C-97” where ADDRESS IS NULL;

30. def push(stack):
s= [ ]
print (“Stack Before Push)
display (stack)
s.‘append(input (“Enter student rollno?”))
s.append(raw_input (“Enter student name”))
s.append (raw_input (“Enter student grade”))
stack.append(s)
def display (stack):
1=len (“STACK CONTENTS”)
for i in range (1-1,-1,-1):
print stack [i]
stack=[ ]
print “Creating stack”
n = input (“Enter the number of students”)
for i in range(n):
push (stack)
display (stack)

Section-D

31. (i) B_TOWN can house the server as it has the maximum no. of computers.
(ii) Optical fibre cable is the best for this star topology

(iii) Switch
(iv) VoIP
(v) MAN (Metropolitan Area Network) will be formed as network would span within a city.

32. (i) r+→ opens a text file for reading and writing.
w+ → opens a text file for writing and reading. It overwrites the file if it exists.
(ii) import pickle
file=open(“log.dat”,‘rb’)
try:
whileTrue:
y=pickle.load(file)
#print y
X=y.find(Xerror) #pos
if X l= –1:
count++
y.split( )
n=ylstrip(‘Xerror:’)
m=int(n)
sum=sum+m
print(“No of error lines”,count)
print(“Error”, sum)
except:
print(‘Error’)

OR (Only for option ii)

from pickle import load, dump
import os
import sys
def bfileCreate(fname):
1= [ ]
sd=[1000;[‘Sal’,12,450]]
with open (fname,‘wb’) as ofile:
while True:
dump(sd, ofile)
ans=raw_input(“want to enter more data Y/N”)
if ans.upper( )= =‘N’:break
x=int(raw_input(“enter admission number of student”))
l=input (“enter name class and marks of student enclosed in [ ]”)
sd[x]=1
ofile.close( )
def bfileDisplay(fname):
if not os.path.isfile(fname)
print(“file does not exist”)
else
(file=open(fname,‘rb’)
try:
while True:
sd[ ]
sd=load(file)
print(sd)
except EOFError
pass
[file.close()
bfileCreat(“Student.dat”)
bfileDisplay(“Student dat”)

33. (i) Attribute : An attribute is a field or column of a table which carries a domain of values related to the table.
(ii) Code :
import mysql.connector as con
db=con.connect(‘localhost’,’ Admin’,’ Admin@123’,’clubdb’)
MYCUR = db.cursor()
MYCUR.execute ("SELECT * FROM MEMBER WHERE ACTIVITY= 'GYM' ")
R=MYCUR.fetchall()
for rec in R:
print (rec[0], rec[1], sep = " ")

Section-E

34. (i) SELECT* FROM ITEMS ORDER BY INAME ASC;
(ii) SELECT INAME, PRICE FROM ITEMS WHERE PRICE > = 10000 AND PRICE <= 22000;
(iii) SELECT TCODE, COUNT (CODE) FROM ITEMS GROUP BY TCODE;
(iv) Update ITEMS Set price=price + price*0.1 where Qty>100;

35. import pickle
def AddStudents ( ):
F= open(“Student.dat”,’wb’)
while True:
Rno = int (input(“Rno:”))
Name = input (“Name: ”)
Percent = float (input (“Percent: “))
L = [Rno, Name, Percent]
pickle.dump(L,F )
Choice = input (“enter more (y/n): “)
if Choice in “nN”:
break
F.close( )
def GetStudents ( ):
Total = 0
Countrec = 0
Countabove 75 = 0
with open (“Student.Dat”, “rb”) as F:
while True:
try:
R = pickle.load(F)
Countrec+=1
Total+=R [2]
if R [2] > 75:
print (R [1], “has percent = “, R [2])
Countabove75+=1
except:
break
if Countabove75==0:
print (“There is no student who has percentage more than 75”)
average=Total/Countrec
print (“average percent of class = “, average)
AddStudents ( )
GetStudents ( )

CBSE Practice Paper Computer Science Class 12

All Practice Paper for Class 12 Exam 2024 

Please Click on Download Now

Share page on