Cblecspu 02
Cblecspu 02
Sample Paper 02
Computer Science (083)
CLASS XII 2024-25
Time: 3 Hours Max. Marks: 70
General Instructions:
1. This question paper contains 37 questions.
2. All questions are compulsory. However, internal choices have been provided in some questions. Attempt
only one of the choices in such questions
3. The paper is divided into 5 Sections- A, B, C, D and E.
4. Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
5. Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
6. Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
7. Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
8. Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
9. All programming questions are to be answered using Python Language only.
10. In case of MCQ, text of the correct answer should also be written.
SECTION A
2. Given the list L = [10, 20, 30, 40, 50], the result of print(L[-2]) is:
(a) 20 (b) 40
(c) 40 (d) 30
6. You can repeat the elements of the tuple using which operator?
(a) * (b) +
(c) ** (d) %
8. Which method retrieves the next row from the result set as a tuple?
(a) fetchone () (b) fetchall ()
(c) fetchmany () (d) rowcount
9. Which of the following command displays the attributes of a table along with their types and sizes?
(a) Alter (b) Show structure
(c) Show create table (d) View structure
14. Given a list Lst = [25, 60, 15, 40, 75]. What will be the output of Lst[: :]?
(a) [25, 60, 15, 40, 75] (b) [ ]
(c) Error (d) [25]
17. In which mode can a file be opened for both reading and writing?
(a) r (b) r+
(c) a (d) None of these
Directions : (Q.Nos. 20 and 21) are Assertion and Reason based Questions.
20. Assertion (A) : To use the randint() function , the random module needs to be included in the program.
Reason (R) : Some functions are present in modules and to use them the respective module needs to be
imported.
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(c) A is true but R is false.
(d) A is false but R is true.
21. Assertion (A) : The contents of a Binary file are not directly interpretable.
Reason (R) : Modes in which binary files can be opened are suffixed with ‘b’ like : rb/wb etc.
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(a) A is true but R is false.
(c) A is false but R is true.
SECTION - B
24. Name two switching techniques used to transfer data between two terminals (computers).
o
Arrange the following network in ascending order of their area:
LAN, PAN, WAN, MAN
SECTION - C
29. Write a function Del() to delete the 4th word from a text file school.txt.
o
Write a function countmy( ) in Python to read the text file “Data.txt” and count the number of times “my”
occurs in the file.
For example If the file contents are:
My first book was. Me and My Family.
It gave me chance to be known to the world.
The output of the function should be
No. of times “my” occur : 2
30. Write Push (contents) and Pop (contents) methods in Python to add numbers and remove numbers
considering them to act as Push and Pop operations of stack.
o
Write the Push operation of stack containing person names. Notice that the name should only accept
characters, spaces and period (.) except digits. Assume that Pname is a class instance attribute.
31. Write a user-defined function find-name (name), where name is an argument in Python to delete phone
number from a dictionary phone-book on the basis of the name, where name is the key.
o
Given below is a code to open a text file and perform some operations on it. Answer questions with respect
to the code given
myfile=open(“detail.txt”, “r”)
s =.......... Line 2
print(s)
myfile.close( )
(i) In which mode is the file opend?
(ii) If the entire file is to be read, write a statement in place of Line 2.
(iii) What is the original code performing?
SECTION - D
32. Does python create a file itself if the file doesn’t exist in the memory? Illustrate your answer with an
example:
Write a program using following functions :
(a) inputStud() :To input details of as many students and add them to a csv file “college.csv” without
removing the previous records.
SrNo Studname City Percentage
(b) readCollege() : To open the file “college.csv” and display records whose city is “Kolkata”
o
Write a statement to create a data.txt file with the following text.
Python file handling is very interesting and useful.
Write a python code using two functions as follows
(a) removerow( ) : To remove a record from the college file “College.csv” having following structure.
SrNo Studname City Percentage
(b) getCollege( ) : To read the records of the college file “College.csv” and display names of students whose
names start with a lowercase vowel.
33. (a) Consider the tables CARS and SUPPLIER given below. What will be the output of the statement
given?
TABLE: CARS
Ccode Car-Name Make Color Capa-city Cha-rges Scode
501 A-star Suzuki RED 3 14 1
503 Indigo Tata SILVER 3 12 2
502 Innova Toyota WHITE 7 15 2
509 SX4 Suzuki SILVER 4 14 2
510 C-Class Merc-edes RED 4 35 4
Table : SUPPLIER
Scode Sname
1 Great Suppliers
2 Himalayan Vehicles
3 Road Motors
4 Speed
SELECT CarName, Sname, Charges FROM CARS C, SUPPLIER S WHERE C.Scode= S. Scode
AND Charges > 15;
(b) Write the output for SQL queries (i) to (iv), which are based on the table CARDEN.
TABLE: CARDEN
Ccode CarName Make Color Capa-city Charges
501 A-star Suzuki RED 3 14
503 Indigo Tata SILVER 3 12
502 Innova Toyota WHITE 7 15
509 SX4 Suzuki SILVER 4 14
510 C-Class Mercedes RED 4 35
(i) SELECT COUNT(DISTINCT Make) FROM CARDEN;
(ii) SELECT COUNT(*) Make FROM CARDEN;
(iii) SELECT CarName FROM CARDEN WHERE Capacity = 4;
(iv) SELECT SUM (Charges) FROM CARDEN WHERE Color = “SILVER”;
34. Write the output of the queries (i) to (iv) based on the table FURNITURE given below.
Table : FURNITURE
FID NAME DATE OF PURCHASE COST DISCOUNT
B001 Double Bed 03-JAN-2018 45000 10
T010 Dinning Table 10-MAR-2020 51000 5
B004 Single Bed 19-JUL-2021 22000 0
C003 Long back Chair 30-DEC-2016 12000 3
35. Sony corporation has set up its 4 offices in the city of Srinagar, with its offices X, Z, Y, U:
X to Z 40 m
Z to Y 60 m
Y to X 135 m
X to U 70 m
Z to U 165 m
Z to U 80 m
Number of computers in each of the offices is as follows:
X 50
Z 130
Y 40
U 15
(i) Suggest a suitable cable layout of connectivity of the offices.
(ii) Suggest placement of server in the network with suitable reason.
(iii) Suggest placement of following devices in the network:
(a) Switch/Hub
(b) Repeater
(iv) Suggest a suitable topology for connecting the computers in each building.
SECTION - E
36. Consider the table APPLICANTS
TABLE: APPLICANTS
No NAME FEE GEN-DER C_ID JOINYEAR
37. (a) Carefully observe the following Python code and answer the question that follow:
x = 5
def func2():
x = 3
global x
x = x + 1
print(x)
print(x)
On execution the above code, produces the following output:
6 3
Explain the output with respect to the scope of the variables.
(b) Write the code to create a table Product in database Inventory with following fields
Fields Datatype
PID varchar(5)
PName char(30)
Price float
Rank varchar(2)
Note the following to establish the connection between Python and MySQL:
Host : localhost
Username : system
Password : hello
Database : Inventory