XII CS Term-1 Question Paper 2024-25
XII CS Term-1 Question Paper 2024-25
General Instructions:
Section A
1. State True or False: “In a Python program, if a break statement is given in a nested loop, it 1
terminates the execution of all loops in one go.”
3. Which of the following commands can be used to read “n” number of characters from a 1
file using the file object <file>?
(a) file.read(n)
(b) n=file.read()
(c) readline(n)
(d) readlines().file
(a) 0.00
(b) 0
1
(c) 1.0
(d) 1
11. The structure of a Python function contains a function header and ____________. 1
(a) return Statement
(b) Indented Block
(c) Function Body
(d) def Statement
12. Fill in the blank: 1
A variable is only available inside a specific region of the program, called it’s
____________.
2
13. Array or linear list comes under the category of__________. 1
(a) Simple Data Structure
(b) Compound Data Structure
(c) Random
(d) None of these
15. In a stack, if a user tries to remove an element from empty stack it is called ___________. 1
(a) Underflow
(b) Empty
(c) Overflow
(d) Garbage Collection
16. Any modification to a global variable is permanent and affects _________ where it is 1
used.
(a) Only one function
(b) All the functions
(c) Only two functions
(d) None of the above
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
Reasoning (R):- Python file method tell() returns the current position of the file
read/write pointer within the file.
Reasoning (R):- Insertion and Deletion takes place from Top of the stack.
Section B
19. Rewrite the code fragment using while loop. 2
3
21. Write a function to push an element into the stack. 2
1
22
333
4444
55555
Section C
26. Define the following: 3
1. Exception Handling
2. Throwing an exception
3. Catching an exception
f=open("quotes.txt")
print(f.read(4))
print(f.read(5))
print(f.read())
28. Write a random number generator that generates random numbers between 1 and 6 3
(simulates a dice).
OR
Write a program to input any number and to check whether the given number is
Armstrong or not.
30. What will be the output produced by the following code statements? 3
(i) 87//5.0*2
(ii) 17%5//3**2
(iii) 2+9*((3*12)-8)/10
4
Section D
For example:
If the lists of customer details are:
[“Ashok”, “9999999999”,”Goa”]
[“Avinash”, “8888888888”,”Mumbai”]
[“Mahesh”,”77777777777”,”Cochin”]
[“Rakesh”, “66666666666”,”Goa”]
The stack should contain: [“Rakesh”,”66666666666”] [“Ashok”,” 99999999999”]
The output should be:
[“Rakesh”,”66666666666”] [“Ashok”,”99999999999”]
Stack Empty
Section E
Example:
35. What is the advantage of using a csv file for permanent storage? 5
Write a Program in Python that defines and calls the following userdefined functions:
(i) ADD() – To accept and add data of an employee to a CSV file ‘record.csv’. Each
record consists of a list with field elements as empid, name and mobile to store
employee id, employeename and employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSVfile named
‘record.csv’.
OR
Give any one point of difference between a binary file and a csv file.Write a Program
in Python that defines and calls the following user defined functions:
(i) add() – To accept and add data of an employee to a CSV file ‘furdata.csv’.
Each record consists of a list with field elements as fid, fname and
fprice to store furniture id, furniture name and furniture price respectively.
(ii) search()- To display the records of the furniture whose price is more than
10000.