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

Section-A 

1. (b) False

Explanation :    

In python blocks are made by indenting statements in levels, not by { }

2. (b) Foreign key

Explanation :    

A foreign key is a non key column that is primary key in another table and links the two tables.

3. (d) 144.0

Explanation :    

The original expressionis:
2**8/2 + 12- 144**0.5 + 16 = 128 +12-12.0 +16
= 144.0

4. (b) 'ypcgalcm'

Explanation :    

s[2: :2] slices the string from index 2 to the end skipping by 1 element.

5. (d) Delete

Explanation :    

The delete command is a DML used to remove records from a table.

6. (a) Star

Explanation :    

Star topology looks like the following :

star topology

7. (d) 125 18

Explanation :    

p+q is a string concatenation , r+s is a normal addition

8. (b) <class ‘type’>

Explanation :    

type () method returns class type of the argument (object) passed as parameter. This function is mostly used for debugging purpose.

9. (d) None of these

Explanation :    

Because every import statement will execute.

10. (b) 30#40#50#

Explanation :    

Maximum value for FROM,TO are 3,4 respectively.

11. (d) WAN

Explanation :    

A network of computers spread across multiple countries can be regarded as a Wide Area Network(WAN).

12. (b) rev=rev*10 +d

Explanation :    

The expression gives the reverse of a number.

13. True

Explanation :    

The code written in else block executes if there is no exception and the code worked fine.

14. (d) Multiple in a relation

Explanation :    

There can be many candidate keys in a table. Out of which one becomes the primary key. The other keys become the alternate key.

15. (c) Network device

Explanation :    

The RJ45 or Registered Jack 45 is a network device connecting the network cable to the NIC.

16. (c) tell()

Explanation :    

The tell() function returns the current position of the file pointer.

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

Explanation :    

When a file is opened , if no mode is specified , the read mode is taken by default.

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

Explanation :    

Any code that needs to be executed , must be defined somewhere.

Section-B

19. (i) (a) Network Interface Card.
(b) Extensible Markup Language
(ii) ARPANET (Advanced Research Projects Agency Network) goal was to connect computers at
different universities and US defense. ARPANET started with a handful of computers but it expanded rapidly.

20. (1) ti*t2 cant multiply
(2) P is in uppercase in print command
(3) t5 is not defined
(4) t1[2] is not possible , as tuples are immutable.

21. def Lfactorial(Lst) :
m=0
f=1
m=min(Lst)
for a in range(1,(m+1)):
f=f*a
return f

OR

def checkSen(sen):
words=0
senlst=sen.split(‘ ‘)
words=len(senlst)
if words % 2==0:
print(“The sentence has even number of words”)
else:
print(“The sentence has odd number of words”)

22. 'weanView9'
S[8] returns the character at index 8 . s[2:] returns characters from index 2 to the end . len(s) returns the
number of characters in the string. All are concatenated together by +

23. (i) Lst.sort(reverse=True).
(ii) Studict[“Marks”]+=5

24. Part I : Describe shop;
Part II : Delete from Shop where Shop_No=255;

25. PYTHON 3.9*39

The function FunStr() copies the contents of the passed argument string to the string T only if they are a digit and then returns the new string. When X = “PYTHON 3.9” is passed to this function it returns 39. Now print statement first prints X and the returned string i.e., 39 with a * in between.

Section-C

26. fUN#pYTHONn#
27. (i) CnoCount(*)   Max(amount)
       101     2                   1500
       103    2                    12000
       (ii) Cno                  Amount
               103                 2000
               101                  1000
       (iii) Count(Distinct Cno)
                      3

28. def COUNTLINES() :
file = open (‘TESTFILE.TXT’, ‘r’)
lines = file.readlines()
count = 0
for w in lines :
if (w[0].lower() not in ‘aeoiu’:
count = count + 1
print(“The number of lines not starting with any vowel : “, count)
file.close()
COUNTLINES()

OR

def ETCount() :
file = open (‘TESTFILE.TXT’, ‘r’)
lines = file.readlines()
countE=0
countT=0
for w in lines :
for ch in w :
if ch in ‘Ee’:
countE = countE + 1
if ch in ‘Tt’ :
counT = countT + 1
print(“The number of E or e :”, countE)
print(“The number of T or t :”, countT)
file.close()

29. (i) SELECT * FROM INTERIORS WHERE TYPE = ‘Sofa’;
(ii) SELECT ITEMNAME FROM INTERIORS WHERE PRICE > 10000;
(iii) SELECT ITEMNAME, TYPE FROM INTERIORS WHERE DATEOFSTOCK < ‘22/01/02’ ORDER BY ITEMNAME DESC;

30. (i) def PUSH(Arr) :
s = []
for x in range (0, len(Arr)):
if Arr [x]%5==0 :
s.append(Arr[x])
if len(s)==0 :
print(“EMPTYStack”)
else :
print(s)

(ii) def popstack(st) : #if stack is empty
if len(st)==NULL :
print(“Underflow”)
else :
l = len (st)
val = st (1 – 1)
print (val)
st.pop (1 – 1)
return val

Section-D

31. (i) TUC should install its server in Human Resource Block as it has maximum number of computers.
(ii)

Human Resource Block

The above layout is based on minimum length cable required, i.e., 140 m.
(iii) Internal Modem : Fixed inside the computer.
External Modem : Attached externally to a computer.
(iv) Switch.
(v) MAN.

32. (i) Difference between Binary file and CSV file: (Anyone difference may be given).

Binary file :

  • Extension is .dat
  • Not human readable
  • Stores data inthe form of 0s and 

CSV file :

  • Extension
  • Human readable
  • Stores data like a text file

(ii) Program:
import csv
def add() :
fout=open(“furdata.csv”, “a”, newline=‘\n’)
wr=csv.writer(fout)
fid=int(input(“Enter Furniture Id : :”)
fname=input(“Enter Furniture name : :”)
fprice=int(input(“Enter price : :”))
FD=[fid,fname,fprice]
wr.writerow(FD)
fout.close()
def search() :
fin=open(“furdata.csv”, “r”, newline=‘\n’)
data=csv.reader(fin)
found=False
print(“The Details are”)
for i in data :
if int(i[2],) > 10000 :
found=True
print(i[0], i[1], i[2])
if found==False :
print(“Record not found”)
fin.close()
add()
print(“Now displaying”)
search()

OR

CSV—Comma Separated Value Program:
def AMCount :
f = open(“story.txt”, “r”)
A, M = 0, 0
r = f.read()
for x in r :
if x[0] == “A” or x[0] == “a” :
A=A+1
elif x[0] == “M” or x[0] == “m” :
M=M+1
f.close()
print(“A or a :”, A)
print(“M or m:”, M)

33. (i) A tuple can be considered to be a row of a table storing complete details of an element or record.
(ii) import MySQLdb
db = MySQLdb.connect(‘localhost’, “FacAdm in’, “FacAdmin@pwd’, college)
cursor=db.cursor()
sql=“““select* from faculty where salary>%F”””
search_value=(12000,)
try.
cursor execute(sql,search_value)
result=curosr.fetchall()
print(“ID, Name, Hiredate”)
for row in result :
ID=row[0]
Name=row[1]+” “+row[2]
Hiredate=row[2]
print(ID, name, Hiredate)
print(cursor.rowcount, “Records found”)
except
print(“Error.can’t Fetch records”)
cursor.close()
db.close()

Section-E

34. (i) SELECT AVG (SALARY) FROM EMPLOYEE GROUP BY DEPTID;
(ii) SELECT NAME, DEPTNAME FROM EMPLOYEE, DEPARTMENT WHERE EMPLOYEE.DEPTID=DEPARTMENT. DEPTID AND SALARY>5000;
(iii) SELECT NAME FROM EMPLOYEE WHERE SALARY IS NULL ORDER BY NAME;
(iv) SELECT DISTINCT DEPTID FROM EMPLOYEE;

35. (i) def Newrecord( ):
fout=open("student.csv","a",newline="\n")
wr=csv.writer(fout)
sid=int(input("Enter Student id : "))
sn=input("Enter Student name : ")
st=int(input("Enter stream : "))
slst=[sid,sn,st]
wr.writerow(slst)
fout.close()

(ii) def Displayrecords( ):
fin=open("student.csv ","r",newline="\n")
data=csv.reader(fin)
for rec in data:
print(rec[0])
print(rec[1])
print(rec[2])
fin.close()
Newrecord( )
Displayrecords( )

CBSE Practice Paper Computer Science Class 12

All Practice Paper for Class 12 Exam 2024 

Please Click on Download Now

Share page on