Cs Model Exam 2024 Question Paper
Cs Model Exam 2024 Question Paper
General lnstructio~s:
• Please check this Question Paper contains 37 questions.
• The paper is divided into 4 Sections - A, B, C, D and E.
• Section A, consists of 21 questions ( I to 21 ). Each ques~ion carries 1 Mark.
• Section B, consists of 7 questions (22 to 28). Each question carries· 2Marks.
• Section C, consists of 3 questions (29 to 31). Each question carries 3 Marks.
• Section D, consists of 4 questions (32 to 35). Each question carries 4 Marks.
• Section E, consists of 2 questions (36 to 37).' Each question carries 5 Marks.
I Q
• All programming questions are to be answered using Python Language only.
• In case of MCQ, text of the correct answer should also be written.
.. Marks
Section-A (21 x 1 = 21 Marks)
No.
State True or False:
1. In a nested loop, a break statement tenninates all the nested loops in one go. [l]
Which of t~e foil owing function returns the total n:um~er of values ?
2. .a)MIN b)MAX c)COUNT d)SUM ' [I]
.
Evaluate the following expression and identify the correct answer.
3., 16 // (4 + 2) * 5 + 2**3 * 4 [1]
( a) 42 b)46 c) 18 d) 32.
Which SQL keyword is used to sort the result-set?
4. a)ORDERBY b) SORT c)ALIGN d)GROUPBY [l]
The set of records retrieved after executing an SQL query over an established
5. database connection is called . [l]
a) table b) resultset c) sqlresult d) result
6. Which of the following method is used to combine two lists in Python? [I]
a) add() .b) append() c) merge() d) extendO
7. Assume that the position of the file pointer is at the beginning of 3rd line in a text file. (I]
Which of the following option can be used to read all the remaining lines?
a) myfile.read(n-3) b) myfile.readlines()
c) myfile.read(n) d) myfile.readlineO
Give the ouiput of the following
8. L= (1,2,3,4,5,6,7,8,9] [l]
print(L[: -1])
I 9.
What happen~ if you try to open a file in 'w' mode that already exists?
a) The file will be opened, and data will be appended to it
b) The file will be opened, and the contents will be cleared [I]
c) An error will be raised
d) The file will be opened for reading
1
. ftuples from the two relations -~
The operation whose result contains alll pairs oa•ch ,
• 'b te va ues m ~ • [l]
· ) Join - . d) Cartesian product
10. regardless of whether thetr at~ u _
_Ja~)~ln~t~ers~e~c~ti~on~_;b~)~S;et~di~ffi~e;r;en~c~e-~
the following Pythonboiicc>
;ifcc;wii·ng]Pyt co e <lle---~--1------.--..
L What error occurs when you execute -
[IJ
. .
11. Snippet ? apple = mango c) ValueErr or d) TypeErro r
a) SyntaxError b) NameError.
• • . • CSV file module in Python. During examinatio1 - - -
Rohit a stuqent of class I~ ts 1earning CSV file 'studeritcsv'. [I]
12. He has been assigned an incomplete code to creahte ad . d CSV File
Help him in completing the code which creates t e estre •
import csv
fh=open( , ,newline='')
Predict the output of the following: [I]
I3. L=[ 1,2,3]
L[0:2]='one'
..
print(L)
Identify the module to which the following function load Obelong to?
14. a) mysql b) ~sv c) p_ic_k_le__•_ _d~)_·s~ys_ _--::-:-- -:---:-- -;--[I_]-i
Which is the valid syntax to write an object onto a binary file opened in the write [I] •
15. mode? .
a·. pickle.dump(<object.to be written>, <file handle of open file>)
b. pickle.dump(<file handle of open file>, <object to be written>)
c. dump. pickle(<object>, <file handle>)
d. None of the above
16. . Choose the correct output for the following stack operation (* top position)
Push(5)
Push(8)
Pop() [I]
Push(2)
Push(5)
PopO
Push(l)
(a) 8 5 2 5 l *. . (b) 8 5 5 2 I* (c) 2 5 5 1• (d) 5 2 l •
17.- If my_diet is a dictionary as defined below, then which of the following stateme~ts
will raise an exception? my_diet= {'apple': Io, 'banana': 20, 'orange': 30} • [I]
a) my_dict.get('orange')
b) print(my_dict['apple', 'banana'])
c) ·my_dict['apple']=20
d) print(str(my_diet))
Which of the f oHowing conun ands is used to remove a table from a database ?
a)Erase b) Kill c) Drop d) Delete [I]
18.
Predict the output of the fallowing:
[I]
19. a) str='CBSE 2024'
\
for a in range(2):
print(str,end=' ')
I
2
Q20 and Q21 are Assertion(A) and Reason(R) based questions. Mark the
correct choice as:
(A)Both A and R are true and R is the correct explanation for A
(B)Both A and R are true and R is not the correct explanation for A
(C)A is True but R is False
(D)A is False but R is True
Assertion (A): Python does not allow programmers to develop the software for
20. several computing platforms by writing a program only once. [I]
Reasoning (R): Python is a cross platform language.
Assertion (A) : If the arguments in the function call statement match the number
21. and order of arguments as defined in the function definition, such arguments are [I]
called positional arguments.
Reasoning (R) : During a function call, the argument list first contains default
argument(s) followed by1he positional argument(s).
Section-B ( 7 x 2=14 Marks)
22. Explain seek( ) method in python. [2]
Give the output of the following :
23. Sum= 0
fork in range( 10, 1, -2): [2]
Sum= Sum+k
print(Sum)
Predict the output ,vith respect to the list L=[40,20,30, i 0,50]
24
• a) >>>print(len(L)) [2]
b) >>>L.pop(); print(L)
c) >>>L.append(70); print(L)
d)>>>L.sort(); print(L)
25. Considering the content stored in file "WORLDCUP.TXT", ,vrite the output·
India won the Cricket world cup of 1983
f=open("WORLDCUP. TXT") [2]
print(f.read(2))
print(f.read(2))
print( f. read(4))
print(f. tell())
f.close()
26. What _possible output(s) are expected to be displayed on screen at the time of
execution of the program from the foil owing code? Also specify the 1naximum [2]
values that can be assigned to each of the variables FROM and TO
import random
AR= [20,30,40,50,60, 70];
FROM=random.randint( 1,3)
TO=random.randint(2,4)
for Kin range(FROM,TO,l):
print(AR[K],end =''#")
3
a)l0#40#70# b) 50#60#70#
c) 40#50#70# d) 30#40#50#
27. A table named School (containing data of students of the whole school) is created,
where each record consists of several fields including AdmissionNo (Admission [2]
Number), RollNo (Roll Number), Name. Which field out of these three should be
set as. the primary key and why?
28. Raj is a ~atabase progrannner, He has to write query from EMPLOYEE table to
search for the employee who are not getting any commission, for this he has written
the query as: [2]
SELECT * FROM Efvfi>LOYEE WHERE co1nmission =null;
But the query is not producing the correct output. Help Raj and correct the query so
that he gets the desired output.
Section-C ( 3 x 3 = 9 Marks)
29. Write read contents from story. txt and count no: of independent words
uto" in the file.
OR (3]
Write a function countVowels() in Python, which should read each character of a
text file "myfile.txt", count the nun1ber of vowels and display the count.
Example: If the "1nyfile.txt" contents are as follows:
This is my first class on Con1puter Science.
The output of the function should be:
Count of vowels in file: l 0
30. Write a Python code to in1ple1nei1t a stack to manage different city names with the
details given below:
MyStack: A stack as a list to hold the city nmnes
MakePush(l\1yStack): To push a city nmne at the top of the stack.
Display(MyStack): Tq display the following.
(i) Top1nost city name (3)
(ii) All the city names of the stack
MakePoP(MyStack) : To remove a city name from the top of the stack. If the stack
is e1npty, display the 1nessage "Underflow" else display the popped out item.
OR
You have a stack nan1ed ORDERS that contains records of orders. Each order record
is represented as a list containing order_no, order_date and address.
Write the follo\ving user-defined functions in Python to perform the specified
operations on the stack ORDERS:
(I) push_order(ORDERS, REC): This function takes the stack ORDERS and a new
order record REC as arguments and pushes the new order record REC onto the
stack.
(II) pop_book(ORDERS): This function pops the topmost order record from the
stack and returns it. If the stack is already en1pty, the function should display
"Underflow".
4
(III) peep(ORDERS)· This fun .
without deleting it th
st
If
~tion displays the topmost element of the stack
. • e ~ck is empty, the function should display 'None'.
Section-D ( 4 x 4 = 16 Marks)
32.. Write SQL commands for the following on the basis of given table STUDENT
No. N•m• Stl,-nd Stream AvgMart< · Gr•d• c,...
'
1 : Karan 400~00
.. Medical 7.8.5 B 1·2B
2 Olvakar - 4'$().00· ·eommerce 89.2 A 11c
3 Otvya 300.00 Commerce 68.6 C 12C:
;
4 Arun 360;00 Hu.manlltu 73~1 B 1·2e
. ; '
OR
5
- .
-
. . .; i
I
.' .. . .
Given Table :CLUB SEX
COACH- AGE SPORTS DATOFAPP- PAY
COACHNAME
ID .
. .
KARATE 1996/03/27 1000 M
I KUKREJA· 35
\
6 KETAKI 36 SWIMMING 1998/02/24 800 F
Table: JOINING
J-ID Department Posting Designation Incentive
JOI Mathematics Agra HOD 8000
J02 Physics Nainital Dean 10000
]03 Chemistry Varanasi Incharge 7500
]04 Computer Kanpur Coordinator 7000
6
- a) Display the total number of departments in the table teacher.
b) Display the details of such teachers who become the most junior and the most
senior.
c) Display the names of the teachers and their departments whose posting is in
Kanpur.
d) Display the details of all physics teachers whose salary is Rs.50,000 or more
and posted in Nainital.
a) Write .a python code to view all the tables which are available-in database named
35. mydatabase. [4]
b) Write a python code to view the structure of a table (say, Company) which is
available in database na1ned mydatabase.
.. SECTION E (2 X S = 10 Marks)
36. a) Write a program to write contents to a binary file stud.dat with record format
[rollno.,name,marks]
[5]
b) Write a program to read contents from the file stud.dat and display those
records whose 1narks >90. Assume stud.dat existing in the system with the record
format [rollno,name,marks]
37. Indian School, in Mwnba.i is starting up the network between its different wings.
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL as
shown below:
ADMIN [5]
I JUNIOR I I HOSTEL I
.IL---_s_EN_ro_R___.j
.
ADMIN TO SENIOR . 200m
ADMIN TO JUNIOR 150m
ADMIN TO HOSTEL 50m
SENIOR TO JUNIOR 250m .
SENIOR TO HOSTEL 350m
JUNIOR TO HOSTEL 350m
The distance between various buildings is as follo,vs
SENIOR 130
JUNIOR ' 80
ADMIN 160
HOSTEL 50
7
J \