0% found this document useful (0 votes)
57 views

Set 1 Comp. Sci Ans. Key

Hnnvccjdjedeudydufydtdtsfjfcivibirdyydyxhxhchxyxyc tu viguffufuvbibobksisbohobowfobowohowwfohwafobafbfbidbdreiowhoafho

Uploaded by

HONEY YOYO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Set 1 Comp. Sci Ans. Key

Hnnvccjdjedeudydufydtdtsfjfcivibirdyydyxhxhchxyxyc tu viguffufuvbibobksisbohobowfobowohowwfohwafobafbfbidbdreiowhoafho

Uploaded by

HONEY YOYO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

SET I

KENDRIYA VIDYALAYA SANGATHAN, MUMBAI REGION

MARKING SCHEME

(MONTHLY TEST – AUGUST 2024) SESSION 2024-25

CLASS-XII SUBJECT- COMPUTER SCIENCE

Max. Marks : 35

SECTION-A
1. True
(1 mark for correct answer)
2. False
(1 mark for correct answer)
3. d) as
(1 mark for correct answer)
4. c) When no exception occurs
(1 mark for correct answer)
5. a) 6.0
(1 mark for correct answer)
6. b) [45, 60]
(1 mark for correct answer)
7. b) File.seek(-10,2)
(1 mark for correct answer)
8. d) are
(1 mark for correct answer)
9. b) Both A and R are true and R is not the correct explanation for A
(1 mark for correct answer)
SECTION-B
10. 115@67@
(2 marks for correct output)
11. a) and b)
Highest and Lowest Values of the label VALUE are as follows:
Highest =13
Lowest=4
(1 mark for possible outputs)
(1 mark for Highest and lowest values)
12. def COUNTLINES():
f=open("ESSAY.TXT","r")
count=0
L=f.readlines()
for line in L:
if line[0] not in 'aeiouAEIOU':
count+=1
print("Number of lines not starting with any vowel is / are = ", count)
f.close()

( ½ Mark for correctly opening the file and reading content of file )
( ½ Mark for the correct loop)
( ½ Mark for correct logic)
( ½ Mark for correctly printing output and closing of file)
13 def CountDigits( ):
f=open("MyData.TXT","r")
s=f.read( )
count=0
for ch in s:
if ch.isdigit( ):
count+=1
print("No. of digits are: ", count)
f.close( )

( ½ Mark for correctly opening the file and reading content of file )
( ½ Mark for the correct loop)
( ½ Mark for correct logic)
( ½ Mark for correctly printing output and closing of file)

SECTION-C
14 def ShowInLines():
f=open("STORY.TXT",'r')
S=f.read()
for W in S:
if W=="." or W=="?" or W=="!":
print(W)
elif W=="\n":
print(end="")
else:
print(W,end="")
f.close()
OR

def LINESTARTS_H():
f=open("News.TXT","r")
L=f.readlines( )
count=0
for line in L:
if line[0]=='h' or line[0]=='H':
count+=1
print("No. of lines start with character H are: ", count)
f.close( )

( ½ Mark for correctly opening the file)


( ½ Mark for reading the content of file using any correct method/mode)
( ½ Mark for the correct loop)
( ½ Mark for correctly checking end of sentence terminating characters)
( ½ Mark for correctly printing normal text without sentence terminator)
( ½ Mark for correctly printing text with sentence terminator)

SECTION-D
15 i.
Pickling: Pickling is the process whereby a Python object hierarchy is
converted into a byte stream.
Unpickling: A byte stream is converted into object hierarchy.
( 1 Mark for correct definition of pickling)
( 1 Mark for correct definition of unpickling)

ii.
import pickle
def CountRecord(Brand):
f=open("PRODUCT.dat", 'rb')
L=pickle.load(f)
count=0
for D in L:
if D[“brand”]==Brand:
count+=1
f.close( )
return count

(½ Mark for importing pickle module and defining the function )


(½ Mark for opening the file in correct mode)
(½ Mark for to read the content of file)
(½ Mark for correct loop)
(½ Mark for correct condition or logic)
(½ Mark for returning the content)
OR
i.
• Versatility: We can perform a wide range of operations, such as
creating, reading, writing, appending, renaming, and deleting files.
• Re-usability: File handling allows us to store the information/data in
secondary storage, after execution of the program.
• User-Friendly
• Cross-Platform: file-handling functions work across different
platforms (e.g. Windows, Mac, Linux), allowing for seamless integration
and compatibility.

(2 marks for any two advantages)

ii.
import pickle
def Display_Record():
f=open("STUDENT.DAT","rb")
L=pickle.load(f)
for D in L:
if D['Marks']>=80 and D['Marks']<=95:
print(D["SName"])
f.close()

(½ Mark for importing pickle module and defining the function )


(½ Mark for opening the file in correct mode)
(½ Mark for to read the content of file)
(½ Mark for correct loop)
(½ Mark for correct condition or logic)
(½ Mark for printing the content)
16 i.
rb+ wb+
Opens an existing file for reading Opens a file for writing and reading. If
and writing. data already exists in the file, it gets
truncated first.
Doesn’t create a new file, if doesn’t Creates a new file if doesn’t exists.
exist.
Does not truncate the file; content Truncates the file to zero length,
remains intact. effectively clearing its contents.

(1 mark for each difference, 2 marks for any two differences)

ii.
import pickle
def Delete_Record():
f=open("PLAYER.DAT","rb+")
L=pickle.load(f)
M=[]
found=0
for D in L:
for pid in D:
if D[pid][1]>18:
found=1
else:
M.append(D)
if found==1:
f.seek(0)
pickle.dump(M,f)
print("Data deleted successfully")
else:
print("No player found whose age is more than 18")
f.close()

(½ Mark for opening the file in correct mode)


(½ Mark for to read the content of file)
(½ Mark for correct loop)
(1 Mark for correct condition or logic)
(½ Mark for use of seek and dump functions)

OR
i.
Absolute path: This is the path of a file in a system which starts from the
root of the file system. It describes the location of a file regardless of the
current working directory. Example: "D:\\python programs\\Book.txt".

Relative path: This is the file path without slash. It describes the location of
a file in relative to the current working directory. Example: “Book.txt”.
( 1 Mark for correct definition of absolute path)
( 1 Mark for correct definition of relative path)
ii.
import pickle
def Modify_Song(s_id):
f=open("SONG.DAT","rb+")
L=pickle.load(f)
M=[]
found=0
for D in L:
for key in D:
if key==s_id:
found=1
D[key][2]=2020
M.append(D)
if found==1:
f.seek(0)
pickle.dump(M,f)
print("Data updated successfully")
else:
print("No song found ")
f.close()
(½ Mark for opening the file in correct mode)
(½ Mark for to read the content of file)
(½ Mark for correct loop)
(1 Mark for correct condition or logic)
(½ Mark for use of seek and dump functions)

17 i.
Text File Binary File
Stores information in ASCII Stores information in the same
characters. format which the information is held
in memory.
Slower than binary files. Binary files are faster and easier for
a program to read and write the text
files.
File extension : .txt File application: as per application

Internal translation takes place. No internal translation.

(2 Marks for any two correct differences)

ii.

import pickle
def Add_Record():
f=open("PEOPLE.DAT", "wb")
n=int(input("How many records you want to add: "))
M=[]
for i in range(n):
Adhaar_number=int(input("Adhaar Number: "))
Name=input("Enter Name: ")
Gender=input("Enter gender: ")
Age=int(input("Enter Age: "))
L=[Adhaar_number, Name, Gender, Age]
M.append(L)
pickle.dump(M,f)
print("Data added successfully")
f.close()
(½ Mark to import pickle module and header of the function )
(½ Mark for opening the file in correct mode)
(½ Mark for input from user and creation of empty list)
(1 Mark for correct loop and taking values from user and creation and appending the list)
(½ Mark for to use dump function)

OR
i.
• Storage Efficiency: Binary files use less storage. Text file uses
additional formatting and encoding.
• Binary files are faster than text files.
• Binary files can store complex data like images, audio etc. whereas text
files are suitable for simple textual format.
(2 marks for correct answer)

ii.

import pickle
def Copy_Book():
f=open("BOOK.DAT", "rb")
L=pickle.load(f)
M=[]
found=0
for record in L:
if record[3]>400:
M.append(record)
found=1
f.close()
fout=open("NEWBOOK.DAT", "wb")
pickle.dump(M,fout)
print("Records successfully copied")
fout.close()

(½ Mark for opening the file BOOK.DAT in correct mode)


(½ Mark for opening the file NEWBOOK.DAT in correct mode)
(½ Mark for reading the content of the file BOOK.DAT)
(½ Mark for the correct loop)
(½ Mark for checking the condition)
(½ Mark for writing the required contents into the file NEWBOOK.DAT)

You might also like