Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

No.

of pages - 7 (M)
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. False 1
2. D 1
3. A 1
4. C 1
5. B 1
6. D 1
7. A 1
8. C 1
9. C 1
10. B 1
11. D 1
12. A 1
13. A 1
14. B 1
15. C 1
16. B 1
17. D 1
18. B 1
SECTION – B
(EVERY QUES CARRY 02 MARK, 2*7=14)
19. 2-4-5-6-2-3-7 or 4-5-6-2-3-7 2
20. def prime(): ½ mark
n=int(input("Enter number to check :: ")) #bracket missing for
for i in range (2, n//2): each
if n%i==0: # = missing error
print("Number is not prime \n")
break #wrong indent
else:
print("Number is prime \n”) # quote mismatch
21. def cube(num = 5): 2
result = num ** 3
print("cube of ", num, "is", result)
cube()
or
def Calci(x,y):
add = x+y
mult= x*y
div = x/y
return add,mult,div
n1 = int(input("Enter 1st number: "))
n2 = int(input("Enter 2nd number: "))
a,m,d = Calci(n1,n2)
print("Addition: ",a)
print("Multiplication: ",m)
print("Division: ",d)
22. a. Error b. 1 1+1
23. Local Variable Global variable 2
It is a variable which is declared It is variable which is declared outside
within a function or within a block. all the functions
It is accessible only within a It is accessible throughout the
function/block in which it is declared program.
Ex. def cube(n):
Data = n*n*n #Data and n are local variables
return Data
x = 10
result = cube (x) # result and x are global variables
print (“Cube of”, x, “is”, result)
Or
When immutable type objects are given as arguments then their value can not
be altered by the function (i.e only value is passed to the function) but when
mutable type objects are passed their reference is passed and hence the values
can be altered.
24. 1* 2
1 *2 *
1 *2 *3 *
Or
48
None 36

2 XII-COMPUTER SC.-M
25. Break statement is used to terminate the execution of the loop. Whereas 2
continue statement is used to skip the statements in present cycle of loop and
continue to the next iteration. For example,
LIST = [3,5,7,8,9,11]
for X in LIST: for X in LIST:
if X % 2 == 0: if X % 2 == 0:
break continue
print (X, end = ‘ ’) print (X, end = ' ')
here, output will be, here, output will be,
357 3 5 7 9 11

SECTION – C
(EVERY QUES CARRY 03 MARK, 3*5=15)
26. Data = {'Rohan':40,'Rihaan':55,'Tejas':80,'Ajay':90} 3
Stk=[]
def PUSH_ITEM (Data):
If (y > 49) :
Stk.append (X)
def POP_ITEM (stk) :
If len (Stk) = =0:
print ("Under flow")
else
while Stk:
name = Stk.pop()
print (name)
PUSH_ITEM (Data)
POP_ITEM (Stk)

27. a. The Pickling process serializes the objects (serialization) and converts them 3
into byte stream so that they can be stored in binary files.
The Unpickling is the reverse operation of pickling (deserialization) where a byte
stream is converted into human readable form i.e. into object hierarchy.

b. newline = ‘’ ensures that no end of line translation would take place while
storing the file on the disk. By default, text files are stored with some text
translations, EOL translation is one of them. This is useful while using the file of
different platforms.
28. def FileRead(): 3
f=open("Myfile.txt","r")
data=f.read()
words=data.split()
for i in words:
if len(i) < 4:
print(i,end=", ")
f.close()

FileRead()
OR
def COPY():
f = open('Story.txt','r')
f1 = open('Result.txt','w')

3 XII-COMPUTER SC.-M
data = f.readlines()
for i in data:
if i[0] == 't' or i[0] == 'T':
f1.write(i)
else:
continue
f.close()
f1.close()

COPY()

29. Exception is that unusual situation in a program, that can cause the program to 3
respond abnormally or produce incorrect outputs.
In Python, exceptions, if any, are handled by using try-except-finally block. While
writing a code, programmer might doubt a particular part of code to raise an
exception. Such suspicious lines of code are considered inside a try block which
will always be followed by an except block. The code to handle every possible
exception, that may raise in try block, will be written inside the except block. If
no exception occurred during execution of program, the program produces
desired output successfully. But if an exception is encountered, further
execution of the code inside the try block will be stopped and the control flow
will be transferred to the except block. For example,
try:
n1 = int(input("Enter first number: "))
n2 = int(input("Enter second number: "))
result = n1 / n2
print("Division operation performed")
except ZeroDivisionError:
print("Division by 0 not possible")
finally:
print("Have a good day!!")
30. a. S.split() 3
b. L.remove('ele')
c. D.pop(‘Delhi’)

SECTION – D
(EVERY QUES CARRY 04 MARK, 2*4=08)
31. import csv 4
f=open("StuDetail.csv","w", newline=’’)
obj = csv.writer(f)
obj.writerow(["rollno","name", "marks"])
record = []
while True:
rno=int(input("Enter Roll no: "))
name=input("Enter Name: ")
marks= int(input("Enter marks: "))
data = [rno,name,marks]
record.append(data)
ch = input("Do you want to continue:(y/n) ")
if ch == "n":
break

obj.writerows(record)
f.close()
4 XII-COMPUTER SC.-M
#Reading a CSV file
f=open("StuDetail.csv","r")
ReadObj=csv.reader(f)
for i in ReadObj:
print(i)
f.close()
32.(a) The default parameters are parameters with a default value set to them. 4
This default value is automatically considered as the passed value when
no value is provided for that parameter in the function call statement.
E.g. def display(name, std=”12”, rollno=”24”):
……………………………………….
……………………………………….
display(“Rohit”)
The keyword parameter gives complete control and flexibility over the
values sent as arguments for the corresponding parameters. Irrespective
of the placement and order of arguments, keyword arguments are
correctly matched.
E.g. def calculate(mp, cp, dis):
…………………………
…………………………
calculate(dis=10,mp=800,cp=600)

(b) city=[]
def PUSH(city,rec):
city.append(rec)

def Display(city):
if city == []:
print("Stack is empty... Nothing to display.")
else:
print("The latest added element of stack is ",city[-1])

while True:
pin=int(input("Enter pincode of city: "))
name=input("Enter name of city: ")
rec=[pin,name]
ch = input("Want to enter more records? (y/n)")
if ch not in 'yY':
break

PUSH(city,rec)
Display(city)

5 XII-COMPUTER SC.-M
SECTION – E
(EVERY QUES CARRY 05 MARK, 3*5=15)
33. a. import pickle 2+3
b. open(‘Mydata.dat’,’wb’)
c. pickle.dump (Slist, F)
d. open(‘Mydata.dat’,’rb’)
e. pickle.load(F)
OR
a. open(‘Stud.dat’,’wb’)
b. pickle.dump(Stud, F)
c. open(‘Stud.dat’, ‘rb’)
d. data = pickle.load(F1)
e. {‘RollNo’: 24, ‘Name’: ‘Ariba’, ‘Marks’: 98}
Eligible for merit.
34. Text file: 5
 Stores information in ASCII or UNICODE charcter
 Each line is terminated by a special EOL (End of Line) charcter.
 Less secured than binary files
 Data can be read and changed easily by anyone as it is in human readable
form
 File extension is .txt
Binary File:
 Stores the data in the same way as stored in the memory.
 There is no delimiter for a new line.
 More secured than text files.
 Data can’t be read and changed easily as it is in binary form.
 File extension is .dat
def LineRead():
f = open("Myfile.txt","r")
lst = f.readlines()
for i in lst:
line = i.split()
if len(line) >= 10:
print(i)
f.close()
LineRead()
OR
Yes, a function can return multiple values in a single return statement. For
example,
def caci(a,b):
return a+b, a-b, a/b, a*b
r,s,t,u= calci(22,4) # OR x = calci(22,4)

Import pickle
def create file():
fobj=open (‘Book.dat’, ‘ab’)
Bookno=int(input(‘Book Number:’))
Bookname=input (‘Name :’)
Author=input (‘Author :’)
Price=int (input (‘Price:’))
rec=[Bookno, Bookname, Author, Price]
pickle.dump (rec, fobj)
fbj.close()

6 XII-COMPUTER SC.-M
def Countrec(Author):
fobg=open (‘Book.dat’, ‘rb’)
num=0
try :
while True:
rec=pickle.load(fobg)
If Author==rec[2]:
num = num+1
except :
fobg.close()
return(num)

35. a. people.csv, ‘r’ 5


b. reader
c. data, J
d. for J in data:
print(J[3])
e.
423578901
435211899
426289736
434124162

7 XII-COMPUTER SC.-M

You might also like