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

Section-A 

1. (a) True

Explanation :    

Python provides the interactive mode for executing single line statements and script mode to execute programs comprising of multiple statements.

2. (a) 1

Explanation :    

According to database rules ,a table or a relation can have a maximum of one primary key.

3. (b) 133

Explanation :    

The original expressionis:
5**3 + 166%7 + 12/4 = 125 + 5 + 3
= 133

4. (b) 4

Explanation :    

count() function returns the number of occurances of the character specified. index() returns the index of the first occurence of the character given.
The expression here gives the sum of number of occurances of ‘o’ and index of ‘o’.

5. (c) CHECK

Explanation :    

The check constraint can be used to provide business rules on columns of a table.

6. (b) Repeater

Explanation :    

A repeater is a device that can amplify signals, so that they reach to a larger distance.

7. (d) All are incorrect.

Explanation :    

A dictionary is not ordered by index and keys are immutable. append() method does not exist for dictionaries.

8. (a) [8, 9, 10]

Explanation :    

The slice of the list gives values from index 2 to 19. Since in the list here, elements upto index 19 are not existing , elements upto the end are displayed.

9. (c) Both (a) and (b)

Explanation :    

Tuples are immutable. So append and insert operations are not possible on tuples.

10. (a) and (d) are the possible output(s)

Explanation :    

Minimum value that can be assigned to Y = 0
Maximum value assigned to Y = 3

11. (a) 4 bytes

Explanation :    

An IP address is of 4 bytes and is temporary.
Example : 155.104.2.1

12. (c) return d

Explanation :    

The return keyword is used to return values from a function.

13. True

Explanation :    

The finally block executes irrespective of whether an exception occurs or not.

14. (c) Joining condition

Explanation :    

In joining multiple tables, the joining condition is compulsory.

15. (d) Gateway

Explanation :    

A gateway is a network device that connects two dissimilar networks, such as a LAN and a WAN.

16. (b) String

Explanation :    

The write( ) function takes as argument a string .

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

Explanation :    

def sum(a=10,b=20)
return (a+b)
In the above code , even if the sum() function is called as sum(30), it will work with values 30,20

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

Explanation :    

Since all the data is arranged separated by a comma. and each record takes up a new line such files are called csv files.

Section-B

19. (i) LAN : Local Area Network
(ii) URL : Uniform Resource Locator.

Twisted pair Optical fibre cable
Carries data using electricity Carries data using light

20. Value = 30
for val in range (0, Value) : #Error 1
if val%4==0 : # Error 2
print (val*4)
elif val%5==0 : # Error 3
print (val + 3)
else : # Error 4
print (val + 10)

21. def sumprime(n):
prime=True
s=0
for i in range(2,n):
if n%i==0:
prime=False
break
if prime==True:
while n>0:
s+=n%10
n//=10
print(“Sum of digits”,s)
else:
print(“Number is not prime”)

OR

def Buzzcount(Lst):
count=0
for n in Lst :
if n%7==0 or n%10==7:
count+=1
print(“Count of buzz numbers :”,count)

22. Output
1 20 P$
4 30 P$R$
9 60 P$R$S$

23. (i) print(Empdict.items())
(ii) print(Lstnum.count(5))

24. ALTER TABLE Product DROP COLUMN Quality;
25. None of the above

Explanation: Since p carries the None literal , which is not equal to 0 and the string “None” , so the statement in else block is executed.

Section-C

26. 20#36#27#100#
27. (i) COUNT(*)    City
               2                 Mumbai
               2                 Delhi
               2                 Moscow

(ii) MAX(DOB)      MIN(DOB)
      08-12-1995
      07-05-1993

(iii) NAME             GENDER
         Sonal               F
         Store               M

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

OR

def displaySheMy():
num=0
f=open(“book.txt”,”r+”)
N=f.read()
M=N.split()
for x in M:
if x.lower()==”she” or x.lower()== “my” :
num=num+1
f.close()
print(“Count of She/My in file:”,num)

29. (i) Select Name from Lecturer where Department=”History”;
(ii) SELECT Name, Age, Department from Lecturer where Name like “_a%”;
(iii) Update Lecturer Set Salary= Salary + Salary *0.05 where Gender=”M” and Department=”Computer
Sc”;

30. NoVowel=[]
def PushNV(N) :
for i in range(lne(N)) :
if ‘A’ in N[i] or ‘E’ in N[i] or ‘I’ in N[i] or ‘O’ in N[i] or ‘U’ in N[i] :
pass
else :
NoVowe1.append(N)[i])
All = []
for i in range (5) :
w=input(“Enter words:”)
All.append(w)
PushNV(All)
while True :
if len(NoVowel)==0 :
print(“EmptyStack”)
break
else :
print(NoVowel.pop(), “ ”, end= ‘ ’)

Output:

Edit Shell Debug Options Window Help
Python 3-10-2 (Lags/v3.10.2 : a 58 ebcc, Jan 17 2022, 14 : 1 AMD64)] on win32
Type “help”, “copyright”, “credits” or “license()” for
____________ RESTART : c:/Users/hp/AppData/Local/Programs/Pyt
Enter Words : DRY
Enter Words : LIKE
Enter Words : RHYTHM
Enter Words : WORK
Enter Words : GYM
GYM RHYTHM DRY EmptyStack

Section-D

31. (i) The most suitable place to house the server is JAMUNA because it has maximum number of computers.
     (ii)

JAMUNA

(iii)

  • Switches are needed in every building to share bandwidth in every building.
  • Repeaters may be skipped as per above layout, (because distance is less than 100 m) however, if building RAVI and building JAMUNA are directly connected, we can place a repeater there as the distance between these two buildings is more than 100 m.

(iv) JAMUNA building, as it has the server placed in it.
(v) MAN

32. (i) Opening a file in “w” mode opens it for writing. If the file already exists it is overwritten. whereas opening a file in “a” mode opens it for appending, that is adding more data, keeping existing data.
(ii) def binfile() :
importpickle
file=open(‘data.dat’, ‘wb’)
while True :
x=int(raw_input(“Enter number”))
pickle.dump(x,file)
ans=raw_input(‘want to enter more data Y/N’)
if ans.upper()==‘N’ : break
file.close()
print(“Reading from file”)
file=open(‘data.dat’, ‘rb’)
try:
while True:
y=pickle.load(file)
print(y)
except EOFError :
pass
file.close()
binfile()

OR

fp1=open(“phonebook.dat”, ‘w’)
fp1.write(“Name”)
fp1.write(“ ”)
fp1.write(“Phone”)
fp1.write(‘\n’)
while True :
name = input(“Enter name:”)
phno = input(“Enter phone no:”)
fp1.write(name)
fp1.write(“ ”)
fp1.write(phno)
fp1.write(“\n”)
ch=input(“Want to enter more = y/n”)
if ch==‘N’ or ch==‘n’ :
break
fp1.close()

33. (i) A cartesian product or a cross join is a join where there is no joining condition and each record of one table is joined to all records of the other table.
(ii) import MySQLdb
db=MySQLdb.connect(“localhost”, “Admin”, “Ad123”, “HMD”)
cursor=db.cursor()
cursor.execute(“DROP TABLE IF EXISTS Location”)
sql=”Create Table Location (id Numeric (5) PRIMARY KEY, bldg_code varchar(10) Not Null, room
varchar(6) Not Null, capacity Numeric (5) Not Null)”
cursor.execute(sql)
db.close()

Section-E

34. (i) SELECT VehicleName From CABHUB WHERE Color = “WHITE”;
(ii) SELECT VehicleName, Capacity FROM CABHUB ORDER BY Capacity ASC;
(iii) DELETE FROM CABHUB WHERE color=’white’’
(iv) ALTER TABLE CABHUB ADD(PNUM integer);

35. (i) import csv
def ADD():
fout=open(“record.csv”,”a”,newline=”\n”)
wr=csv.writer(fout)
empid=int(input(“Enter Employee id :: “))
name=input(“Enter name :: “)
sal=int(input(“Enter salary :: “))
lst=[empid,name,sal]
wr.writerow(lst)
fout.close()

(ii) def COUNTR():
fin=open(“record.csv”,”r”,newline=”\n”)
data=csv.reader(fin)
d=list(data)
print(len(d))
fin.close()

CBSE Practice Paper Computer Science Class 12

All Practice Paper for Class 12 Exam 2024 

Please Click on Download Now

Share page on