You are on page 1of 8

No.

of pages - 8 (E)
MARKING SCHEME
MID-TERM EXAMINATION (2023-24)
CLASS : XII
SUBJECT: COMPUTER SCIENCE (083)
Time Allowed : 3 hours Maximum Marks : 70
GENERAL INSTRUCTIONS:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 02 questions carrying 04 marks each.
7. Section E has 03 questions carrying 05 marks each.
8. All programming questions are to be answered using Python Language only.
*************

SECTION – A
(EVERY QUES CARRY 01 MARK,
1*18=18)
1. TRUE 1
2. C 1
3. A 1
4. D 1
5. B 1
6. C 1
7. B 1
8. A 1
9. B 1
10. A 1
11. C 1
12. C 1
13. TRUE 1
14. B 1
15. C 1
16. B 1
17. C 1
18. A 1

1 XII-COMPUTER SC.-E
SECTION – B
(EVERY QUES CARRY 02 MARK, 2*7=14)
19. 41 2
20. data = 40 ½ mark
for x in range(0, data): # colon missing for
if data % 4 == 0: #correct operator is == each
print (data * 4) error
elseif data % 5 == 0: #it should be elif
print (data + 3)
else: #colon missing
print (data +10)

21. def Names(N): 2


for x in N:
if x[0] == ‘a’ or x[0] == ‘A’:
print(x)
N= [‘Ashima’, ‘Neha’, ‘Rahul’, ‘Ishaan’, ’Ashu’, ‘Kirti’]
Names(N)
OR
K = [14,25,16,23,12,9,7,23]

def SumEvenOdd(K):
ESum=OSum=0
for i in K:
if i % 2 == 0:
ESum = ESum + i
else:
OSum = OSum + i
print("Sum of Even Numbers: ",ESum)
print("Sum of Odd Numbers: ",OSum)
SumEvenOdd(K)

22. A 1+1
BB
CCC
DDDD
EEEEE
FFFFFF
23. Scope of a variable refers to the area or block of code where the variable is 2
accessible or valid. A variable can be in local scope if it is defined within the
function i.e. it cannot be accessed/used outside the function. Similarly, a variable
declared outside the function (declared in the main program) is considered to be
in global scope as it can be accessed in the whole program.
If we want to change the value of a global variable inside the function then we
have to use global keyword. For example,
A = 20 # Global variable A
def Try(x): #Value of x will be 20
A = 10 #Local variable A
A= A + x #Local variable updated A = 10 + 20
print(A) # 30 printing B local variable
print(A) # 20 printing A global variable
Try(A) #Function call
print(A) #20 as A here is global variable
2 XII-COMPUTER SC.-E
OR
The values being passed through a function call statement are called arguments/
actual arguments/ actual parameters. The values received in the function
definition are called parameters/ formal parameters/ formal arguments. For
example,
def Add(a,b): #a,b are formal arguments.
return a+b
x = int (input (“Enter 1st number: “))
y = int (input (“Enter 2nd number: “))
Add(x,y) #x, y are actual arguments.

24. New List is: [2, 1.0, 6, 2.0, 10, 3.0, 14, 4.0, 18] 2
OR
[10, 20, 30, 110]
[100, 100, 100, 100]
25. The flush() function forces the writing of data on disk stored in buffer. If flush() is 2
not used then the data will be written in file only when file will be closed.
For example,
myfile=open("temp2.txt","w+")
myfile.write("hello")
myfile.write("welcome to python world")
myfile.flush()
n=input("press any key")
myfile.write("programming simplified")
myfile.close()

3 XII-COMPUTER SC.-E
SECTION – C
(EVERY QUES CARRY 03 MARK,
3*5=15)
26. a. 30 times 3
b. 6 times
c. 1 time
27. Text file vs binary file 3
Text files:
Extension is .txt
Data is stored in ASCII or UNICODE format that is human readable.
Has EOL character that terminates each line of data stored in the text files.
Can be easily read and changed by anyone.
Binary Files
Extension is .dat
Data is stored in binary form (0s and 1s), that is not human readable.
No EOL character is there in binary files.
Can not be changed or read easily as it is in binary format.
OR
read(): read() function reads the whole text file at once. If we pass an integer
value as an argument then the specified number of characters will be read from
file. It returns a string. Syntax: f.read([n])
readlines(): readlines() function reads all the lines of text file and returns a list of
string. Syntax : f.readlines()
28. def CountLines(): ½ mark
F = open(‘Story.txt’,’r’) for
Lines = F.readlines() opening
Count = 0 file, ½
for x in Lines: marks for
if x[0] == ‘T’ or x[0] ==’t’: reading all
Count += 1 lines and
print(“No. of lines starting with A are : “, Count) using
F.close() loops, ½
OR marks for
def Count_my(): checking
F = open(‘Data.txt’,’r’) condition,
Count = 0 ½ mark
Data = F.read() for
Word = Data.split() printing
for x in word: lines.
if x == ‘my’:
Count += 1
print(‘my occurs’,count,’times’)
29. def BRecord (): 3
book=[]
while True:
b_no = int(input("Enter book number: "))
b_name = input("Enter book name: ")
data=[b_no, b_name]
book.append(data)
ch = input("Want to enter more records(y/n): ")
if ch in 'nN':
break

4 XII-COMPUTER SC.-E
30. a. Pickling: it is a process which converts Python objects into a byte 3
stream.
Unpickling: It is the inverse of pickling process in which a byte stream
is converted into an object.

b. r+ :
-- opens the file if it exist, if not found it shows file not found error.
-- if file exists, file pointer is positioned at the beginning of the file.
-- read and write both possible.
-- Previous data get deleted.
w+:
-- opens the file for both writing and reading
-- file get created if doesn’t exist.
-- existing content get deleted
-- pointer is at the beginning always.

c. text= no module required


binary= pickle module
csv= csv module

5 XII-COMPUTER SC.-E
SECTION – D
(EVERY QUES CARRY 04 MARK, 2*4=08)
31. ½ mark for importing csv module 4
1½ marks for INSERT()
1½ marks for FIND()
½ mark for closing file

32. 1. pickle 4
2. T = open(‘temp.dat’,’wb’)
3. Pickle.load(f)
4. pickle.dump(rec,t)

6 XII-COMPUTER SC.-E
SECTION – E
(EVERY QUES CARRY 05 MARK, 3*5=15)
33. 2+3
Vcount=Ccount=Dcount=Wcount=Spcount = 0
with open('Story.txt', 'r') as file:
content = file.read()
for i in content:
if i.isalpha():
if i in 'AEIOUaeiou':
Vcount += 1
else:
Ccount += 1
elif i.isdigit():
Dcount += 1
elif i.isspace():
Wcount += 1
else:
Spcount += 1
print("Vowels: ",Vcount)
print("Consonants: ",Ccount)
print("Digit: ",Dcount)
print("Words: ",Wcount+1)
print("Special charcters: ",Spcount)
34. 5
1. D
2. A
3. C exception
4. B [4,7]
5. B append a sublist[4,5,6] into L.
OR

1. 23
2. 6
3. 54 will be replaced in place of ‘Delhi’
4. Error will be generated as string cannot be joined with float

5. [4.87, [23, 7.56, ‘Neha’]

35. a. def LenColors(Fname, N): , LenColors(Fname, N) 5


b. open(Fname,’w’) as F:
c. if len(c) >=N:
d. F.write(c+’\n’)
e. Orange
Crimson
Magenta
Fuschia
OR

7 XII-COMPUTER SC.-E
a. open(‘Demo.txt’,’r’)
b. Ch = F.read(1)
c. if Ch in ‘0123456789’:
Dcount += 1
d. elif Ch in '@#-':
Count += 1
e. Count 1:0
Count 2:0

8 XII-COMPUTER SC.-E

You might also like