Xii CS Quarterly 2425 Ans

You might also like

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

SAMADH HIGHER SECONDARY SCHOOL

KHAJA NAGAR, TRICHY


QUARTERLY EXAMINATION 2024-25
Class : XII- A&B Computer Science Time : 3:00 hrs
Subject code: 083 ANSWER KEY Maximum Marks : 70

SECTION –A
Q Question Marks
No.
1. State True or False (R) (1)
Ans. True
2. Ans. (b) return (U) (1)
3. Ans. (b) Tup.insert (2, 3) (U) (1)

4. Ans. (a) False (A) (1)


5. Ans. (d) ('Amrit','' , 'Mahotsav @ 75') (A) (1)
6 Ans. (d) a (A) (1)
7. Ans. (a) sort() (A) (1)
8. Ans. (b) != (U) (1)
9. (a) Statement 2 (1)
OR (A)
(d) Statements 2 and 4
(1 mark for writing correct answer as (a))
OR
(1 mark for writing correct answer as (d))
OR
(1 mark for writing (a) and (c) as the correct answers)
OR
(Only ½ mark for writing (c) as the correct answer
10. Ans. (a) keyword (U) (1)
11. Ans. (a) 0 (A) (1)
12. Ans. (b) Flow of execution (U) (1)

13. Ans. (c) newline (A) (1)


14. Ans. (b) 8.0 (E) (1)
15. Ans. (c) infi.readline( ) (U) (1)
16. Ans. (c) F=open(‘Notes.txt’, ‘A’) (U) (1)

17. Ans. (a) Both (A) and (R) are true and (R) is the correct explanation (1)R
for (A).

18. Ans(d) (A) is false but (R) is true.. (1)R


SECTION – B
19. def max_num (L) : (2)
max=L[0] (U)
for a in L:
if a > max:
max=a
return max
20. Keyword is a special word that has a special meaning ans pupose. (2)
Keywords are reserved and few. For example if, elif.
(R)
Identifier is the user-defined name given to a part of program. Variable,
object, function. Identifiers are not reserved. These are defined by the user
but they can have letters, digits and a symbol underscore. They musr begin
with either a letter or underscore. For instance, _chk, chess.

21. a) Ans. ['Rajat', 'Rajan', 'Ashish'] (1+1)


(A)
b) Ans. 1
22. (a) 13 (1+1)(E)
(b) False
23. (a) i) Tab Separated Values (1+1)
ii) Comma Separated Values
(R)
(b) A file in itself is a bunch of bytes stored on some storage device like
hard-disk, thumb-drive
24. output: 2
['CSCS','HINDIHINDI','PHYSICSPHYSICS','CHEMISTRYCHEMISTRY'
(A)
,'MATHSMATHS']
25. Local variable: 2
1, It is a variable which is declared within a function or within a block (R)
2. It is accessible only within a function/block in which is declared

Global variable:
1. It is variable which is declared outside all the function
2. It is accessible throughout the program
def cube(n):
cn=n*n*n
return
x=10
xcubed=cube(x)
print(x,”cubed is”, xcubed)
SECTION – C
26. def LShift(Arr,n): (3)
L=len(Arr)
(A)
for x in range (0,n):
y=Arr[0]
for i in rane90,L-1):
Arr[i]=Arr[i+1]
Arr[L-1]=y
Print(Arr)

27. def LongLines(): (3)


myfile=open('LINES.TXT') # ignore 'r' mode
(A)
all_lines=myfile.readlines()
for a line in all_lines:
if(len(aline.split()>=10):
print(aline)
myfile.close()
28. (i) <filehandle> =open(<filename>,<readmode>) (3)
try :
(U)
<object>= pickle.load (<filehandle>)
# other processing statements
except EOFError:
<filehandle>.close( )

(ii) with open(<filename>, <mode> as <file handle>:


<file manipulation statements>
# use picle.load here in this with block
# perform other file manipulation task in this with block

29. def EOReplace(L): (3)


for i in range(len(L)):
(A)
if L[i]%2==0:
L[i]=L[i]+1
else:
L[i]=L[i]-1
print(L)
30. Function header: def processNumber(x): (3)
Function call : processNumber(y)
(u)
Arguments : y
Parameters : x
Function Body : x=72
return x+3
Main program : y=54
res=processNumber(y)
SECTION – D
31. count=int(input(“How many students are there in the class?”)) (5)
fileout=open(“Marks.txt”,”w”)
(U)
for i in range(count):
print(“Enter details for student”,(i+1),”below:”)
rollno=int(input(“Rollno☺)”
name=input(“Name:”)
marks=float(input(“Marks:”))
rec=str(rollno)+”,”+name+”,”+str(marks)+’\n’
fileout.close()

32. 1. def factorial(n): (3)


2. fact=1
3. for i in range(1,n+1):
4. fact=fact*i
5. return fact
(U)
6. x=int(input("Enter number:"))
7. result=factorial(x)
8. print("Factorial of",x,"is:",result)

Flow of execution (2)(A)


1→6→7→1→2→3→4→5→8
33. CSV files (2+3)
● can be viewed in spreadsheets
(R) (U)
● module CSV has to be imported
Text files
● can be viewed in the text editor
● No specific module required to be imported
(any other valid difference - any one)
import csv
def COURIER_ADD() :
f1=open("courier.csv","a",newline="\n")
writ=csv.writer(f1)
cid=int(input("Enter the Courier id"))
s_name=input ("Enter the Sender Name")
Source=input("Enter the Source Address")
destination=input("Enter Destination Name")
detail=[cid,s_name,Source,destination]
writ.writerow (detail)
f1.close()
def COURIER_SEARCH() :
f1=open("courier.csv","r") # ignore newline
detail=csv.reader(f1)
name=input("Enter the Destination Name to be searched")
for i in detail :
if i[3]==name:
print("Details of courier are: ",i)

COURIER_ADD()
COURIER_SEARCH()
SECTION – E
34. 300 @ 200 (4)
300 # 100
(A)
150 @ 100
300 @ 150
35. i) Statement 1: open ("Cust_file.dat", "wb") (1)(CB)
Note: 'ab' mode also be considered

ii)Statement 2: qty<10 : (1)

iii)Statement 3: pickle.dump(c_detail,bin_file)
Statement 4: break (2)

You might also like