cblecspu07
cblecspu07
cblecspu07
Sample Paper 07
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
print(b)
(a) 31 (b) 33
(c) 36 (d) 39
15. Which clause is used to group records based on shared values within a specific field?
(a) JOIN (b) GROUP
(c) GROUP BY (d) AGGREGATE
16. Which Python function appends the elements of one list to the end of another list?
(a) join() (b) add()
(c) append() (d) extend()
17. Which of the following functions will read entire contents of a text file?
(a) read() (b) readfull()
(c) readline() (d) readfile()
19. Which protocol serves as the foundation for all application protocols?
(a) FTP (b) TCP/IP
(c) IRCP (d) Telnet
20. Assertion (A) : Pickling is a way to convey a Python object into character stream.
Reason (R) : To perform pickling, the pickle module needs to be imported.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true. A.
SECTION B
22. Examine the code provided below and determine the output:
s = “oceanview”
count = 0
for a in s:
if a in “stuv”:
count += 1
print(count)
24. Provide a detailed explanation of a database and a Database Management System (DBMS).
print(x, y)
x = “hi” + “there”
y = len(x)
print(y, x)
o
Write function names for the following with respect to strings.
(i) To make the first letter of a string in capital
(ii) To find the index of the 1st occurrence of a string in another
SECTION C
29. Write a Python program to open a binary file named “College.dat,” which contains student records with
the structure:
Roll Name SemPercentage
The program should display only the records of students whose percentage is above 30.
o
Create a method countopen() to count and display the number of lines that start with the word “OPEN”
(case-insensitive) in a text file named “start.txt”.
For example, if “start.txt” contains the following lines:
Get the data value to be deleted,
Open the file for reading from it.
Read the complete file into a list
Delete the data from the list
Open the file
Open same file for writing into it
Write the modified list into file.
Close the file.
The method should display
Total lines started with word ‘OPEN’ is/are: 3
30. Describe the traversal operation in a stack and provide the algorithm for traversing a stack to display its
contents. There is no need to write the actual code.
o
Find the final contents of a stack that encounters the following tokens.
Assume that an operand is pushed to stack and a binary operator pops two operands from stack and pushes
the result to the stack.
7,11,*,80,+,50,+
31. Write a user-defined function that accepts a string and checks whether it is a palindrome (a string that reads
the same forwards and backwards).
o
A program in python to modify records of a binary file “hotel.dat” using random access. The program would
accept the room id , search the record by random access and display. It will then accept the new data and
modify the file.
The file structure is :
Roomld Customer Name Days
import pickle
1st=[]
f=open(“hotel.dat”, “rb+”)
ans=‘y’
while ans==‘y’:
r=int(input(“Enter roomid to
modify :”))
1st=pickle.load(f)
size=f.tell()
f.seek(0)
f.seek((r-1)*size)
1st=pickle.load(f)
print(“old record ”)
print(“Room Id :”, 1st[0])
print(“Customer :”, 1st[1])
print(“Days :”, 1st[2])
f.seek(0)
... ... ... # Statement 1
print(“Enter new record ”)
nm=input(“Enter, customer name
:”)
days=input(“Enter days :”)
rs=str(r)
1st=[rs,nm,days]
pickle.dump(1st,f)
ans=input(“Modify another(y/n)”)
f.close()
(i) What type of data is returned by the load() method?
(ii) Which method closes a binary file?
(iii) What will be inserted in statement 1?
SECTION D
32. (a) Underline the errors in the following code and write the correct code:
s= WelcometoCS”
For a IN s :
If a IN “aeiou” :
print(a)
else
print(“False”)
(b) Write a code in Python to update the class of a student to 12 whose roll number is 22. The table
structure is as follows :
RollNo Name Class Perc
Note :
Database : PythonDB
Table : Student
Host : localhost
UserId : root
Password : arihant
o
(a) Write the output of the following function
def showOutput( ):
num=4 + float(7)/int(2.0)
print(“num =”, num)
(b) Write a code in Python to delete the record of a student whose rollno is 33. The table structure is as
follows
RollNo Name Class Perc
Note :
Database : PythonDB
Table : Student
Host : localhost
UserId : root
Password : arihant
Table : PERSON
P_Id Last_Name First_Name City
1 Sharma Abhay Mumbai
2 Gupta Mohan Delhi
3 Verma Akhil Mumbai
Table : ORDERS
O_Id Order_No P_Id
1 10050 3
2 25000 3
3 5687 1
4 45000 1
5 35000 15
With respect to the tables given above write a command to display the Lastname, Firstname and
corresponding order number arranged by Lastname.
(b) With respect to the table PAYMENTS given below, write, output of the following questions.
TABLE : PAYMENTS
Empld Emp_Name Salary Department
1 Ridhi 20000 D1
2 Rohit 25000 D2
3 Rakesh 20000 D2
4 Roshan 44000 D1
5 Rohini 15000 D3
6 Radha 14000 D1
(i) To display the average of employees salary from PAYMENTS table.
(ii) To count the total number of employees from PAYMENTS table Department wise
(iii) To count distinct values of column Department from PAYMENTS table.
(iv) To display department wise number of employees , but for only those departments where number of
employees are more than 2.
34. Write SQL commands from (i) to (iv) on the basis of the table INTERIORS given below
TABLE : INTERIORS
No ITEMNAME TYPE DATEOF-STOCK PRICE DISC-OUNT
1 Red rose Double Bed 23/02/02 32000 15
2 Soft touch Baby cot 20/01/02 9000 10
3 Jerry’s home Baby cot 19/02/02 8500 10
4 Rough wood Office Table 01/01/02 20000 20
5 Comfort zone Double Bed 12/01/02 15000 20
6 Jerry look Baby cot 24/02/02 7000 19
7 Lion king Office Table 20/02/02 16000 20
8 Royal tiger Sofa 22/02/02 30000 25
9 Park sitting Sofa 13/12/01 9000 15
10 Dine Paradise Dining Table 19/02/02 11000 15
11 White Wood Double Bed 23/03/03 20000 20
12 James 007 Sofa 20/02/03 15000 15
13 Tom look Baby cot 21/02/03 7000 10
(i) To show all information about the Sofa from the INTERIORS table.
(ii) To list the ITEMNAME, which are priced at more than 10000 from the INTERIORS table.
(iii) To list ITEMNAME and TYPE of those items, in which DATEOFSTOCK is before 22/01/02 from the
INTERIORS table in descending order of ITEMNAME.
(iv) To insert a new row in the INTERIORS table with the following data
{14, ‘TrueIndian’, ‘Office Table’, ‘25/03/03’, 15000, 20}
o
Write the command to display the sum of prices of items of type “cot”.
35. What is the purpose of the writerows() function for handling CSV files?
A binary file named “Hotel.dat” stores hotel customer details with the following structure:
Roomld CustomerName Days
Write a program in python for adding and displaying records from the binary file using following functions
(a) Reserve() : To add data of customers to the binary file.
(b) ShowReservations() : To open the file “Hotel.dat” and display all the records.
SECTION E
36. Tech Up Corporation (TUC) is a professional consultancy firm planning to establish new offices in India, with
Hyderabad as its central hub. As their network consultant, you are tasked with assessing their requirements
and recommending optimal solutions. Their queries are listed below from (i) to (v).
Physical locations of TUC’s blocks:
Block Computers
Human Resource 125
Finance 25
Conference 60
(i) What will the most appropriate block, where TUC should plan to install their server?
(ii) Draw a block to block cable layout to connect all the buildings in the most appropriate manner for
efficient communication.
(iii) Write names of different types of Modems.
(iv) Which of the following devices will be suggested by you to connect each computer in each of the
buildings?
(a) Gateway (b) Switch (c) Modem
(v) Company is planning to connect its Block in Hyderabad which is more than 20 km. Which type of
network will be formed?
TABLE : INTERIORS
No ITEM NAME TYPE DATE OF STOCK PRICE DISCOUNT
1 Red rose Double Bed 23/02/02 32000 15
2 Soft touch Baby cot 20/01/02 9000 10
3 Jerry’s home Baby cot 19/02/02 8500 10
(i) What should be the data type for the DATEOFSTOCK column?
(ii) Write a command to add a new record as follows :
4, “Morris”,”Sofa Set”
Rest of the field values are not given
(iii) Write statements to :
(a) Write a command to display only the Column ITEMNAME, Net Amount(PRICE-DISCOUNT)
(b) Display only ITEMNAME and Discount column.
o
(Option for part (iii) only)
(a) Which clause is to be used to search non blank values in the table?
(b) Which command will be used to make the “No” column as the primary key?
EN