Class Xii Computer Science Final Mock Test Paper Ms
Class Xii Computer Science Final Mock Test Paper Ms
General Instructions:
Page No. 1
for i in range (2, n//2):
if n%i==0: # = missing
print("Number is not prime \n")
break #wrong indent
else:
print("Number is prime \n”) # quote mismatch
(½ mark for each correct correction made and underlined.)
21 PLACES= ["Delhi","London","Paris","New York","Doha"]
def countNow(PLACES):
for p in PLACES :
if len(p) >5 :
print(p.upper())
countNow(PLACES)
OR
STRING="Come let us have some fun"
T_ID FARE
ii. 101 4500
102 4000
Page No. 2
28
OR
ii. Program:
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 :: ")
mobile=int(input("Enter mobile number :: "))
lst=[empid,name,mobile] ---------1/2 mark 4
Page No. 3
wr.writerow(lst) ---------1/2 mark
fout.close()
def COUNTR():
fin=open("record.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(len(d))
fin.close()
ADD()
COUNTR()
(1 mark for advantage
½ mark for importing csv module
1 ½ marks each for correct definition of ADD() and COUNTR()
½ mark for function call statements)
OR
Difference between binary file and csv file: (Any one difference may be given)
Binary file:
Extension is .dat
Not human readable
Stores data in the form of 0s and 1s
CSV file
Extension is .csv
Human readable
Stores data like a text file
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()
Page No. 4
add()
print("Now displaying")
search()
(1 mark for difference
½ mark for importing csv module
1 ½ marks each for correct definition of add() and search()
½ mark for function call statements
)
33 i. Building 3 , Maximum no of Computers ½ Mark for Naming and ½ for reason.
ii. Any suitable layout 1 Mark for correct layout.
iii. i. switch in all buildings, as more than one computers used.
ii. Repeater from Building 1 to Building 3, as distance is more than 100 m.
iv. Optical Fiber, can be used for high speed wired connection.
v. Telnet 1x5 =5
34 (i)
r+ mode:
1) Primary function is reading
2) File pointer is at beginning of file
3) if the file does not exist, it results in an error
w+ mode:
1) primary function is writing
2) if the file does not exist, it creates a new file.
3) If the file exists, previous data is overwritten
4) File pointer is at the beginning of file
(ii)
OR
(i) Text files:
a. Extension is .txt
b. Data is stored in ASCII format that is human readable
c. Has EOL character that terminates each line of data stored in the text files
Binary Files 5
Page No. 5
a. Extension is .dat
b. Data is stored in binary form (0s and 1s), that is not human readable.
ii.
OR
i. One marks for correct difference.
ii.
Statement 1:
mysql.connector
Statement 2:
con1.cursor()
Statement 3:
mycursor.execute("select * from student where Marks>75")
Statement 4:
con1.commit() 1+4=5
Page No. 6