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

Class 12 Computer Science

Uploaded by

sahilanjum819
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Class 12 Computer Science

Uploaded by

sahilanjum819
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

NO.

1 AIR FORCE SCHOOL, GWALIOR


UNIT TEST – 1 (2024-25)
CLASS - XII
SUBJECT – COMPUTER SCIENCE (083)
MARKING SCHEMA(SET-B)
Date : 22/07/2024
Time Allowed: (1 1/2 Hrs.) Marks: 35

SECTION A

1. (a) pickle (b) math 1

2. (a) End Of Line 1

3. (b) r 1

4. (a) both function name and parameter list 1

5. Output: 4 1

6. c) def correct(a=1,b=2,c=3) 1

7. (b) formal arguments 1

8. (c) 1

9. (b) 1

SECTION B

10. Ans: 2
“w” is used to write in file from the beginning. If file already exists, then it will
overwrite the previous content.

“a” (append – add at the end ) is also used to write in file. If file already exists
it will write after the previous content i.e. it will not overwrite the previous
content and add new content after the existing content
11. Ans: 2

str1 = f.readline() str2 = f.readline()


str3 = f.readlines() OR str3 = f.read()
or
for line in f :
print(line)
12. Ans: 2

Output
300 @ 200
300 @ 100
120 @ 100
300 @ 120
13. 2

SECTION C

14. Ans: 3

 r – to read from the file


 w – to write into the file
 a – append data into the file already exists
 r+/w+ – to perform read and write together
 rb/wb/ab – read, write and append data into binary files

15. Ans: 3
def COUNTLINES():
file=open('STORY.TXT','r')
lines = file.readlines()
count=0
for w in lines:
if w[0]=="A" or w[0]=="a":
count=count+1
print(“Total lines “,count)
file.close()

or

def displayMeMy():
num=0
f=open("story.txt","rt")
N=f.read()
M=N.split()
for x in M:
if x=="Me" or x== "My":
print(x)
num=num+1
f.close()
print("Count of Me/My in file:",num)
16. Ans: 3
def INDEX_LIST(L):
indexList=[]
for i in range(len(L)):
if L[i]!=0:
indexList.append(i)
return indexList

SECTION D

17. Ans: 4
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()

SECTION E

18. Ans: 2+3


i.

ii. import pickle

def findBook(price):
with open('BOOK.DAT', 'rb') as file:
while True:
try:
book_record = pickle.load(file)
for item in book_record:
book_price = book_record[item][2]
if book_price >= price:
print(item, book_record[item])
except EOFError:
break
findBook(50)

You might also like