0% found this document useful (0 votes)
146 views

CS_QP_SET-4

The document is a mock practice exam for computer science, consisting of 37 questions divided into five sections, covering various topics including Python programming, SQL commands, and data structures. Each section has a different marking scheme, with questions ranging from true/false to programming tasks and SQL queries. The exam emphasizes the use of Python for programming questions and includes both theoretical and practical components.

Uploaded by

daredevil09a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
146 views

CS_QP_SET-4

The document is a mock practice exam for computer science, consisting of 37 questions divided into five sections, covering various topics including Python programming, SQL commands, and data structures. Each section has a different marking scheme, with questions ranging from true/false to programming tasks and SQL queries. The exam emphasizes the use of Python for programming questions and includes both theoretical and practical components.

Uploaded by

daredevil09a
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

MOCK PRACTICE 2025

CS (SET-4)
GENERAL INSTRUCTIONS

● This question paper contains 37 questions.


● All questions are compulsory. However, internal choices have been provided in some questions.
Attempt only one of the choices in such questions.
● The paper is divided into 5 Sections- A, B, C, D and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● 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.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of the correct answer should also be written.

Q
Section-A (21x1=21 Marks) Marks
No
State True or False
1 ‘In Python delimiters and operators are the same’ (1)

Identify the output of the following code snippet-

text = ‘COMPUTER SCIENCE IS FUN’


text=text.split('C')
print(text)
2 (1)
(A) ‘COMPUTER SCIENCE IS FUN’
(B) [‘OMPUTER S’, ‘IEN’, ‘E IS FUN’]
(C) [‘COMPUTER’,’SCIENCE’, ‘IS’, ‘FUN’]
(D) [‘’, ‘OMPUTER S’, ‘IEN’, ‘E IS FUN’]

The ________ statement in SQL deletes all the content of a table.


3 (A) DEL * FROM TABLE (B) DROP TABLE (1)
(C) TRUNCATE TABLE (D) None of the above
What will be the output of the following code snippet?

txt = ‘I could eat bananas all day’


x = txt.partition (‘bananas’)
4 print(x) (1)

(A) ‘I could eat all day’ (B) [‘I could eat ‘,’ all day’]
(C) (‘I could eat ‘, ‘ all day’) (D) (‘I could eat ‘, ‘bananas’, ‘ all day’)
What will be the output of the following code?
5 message=’I Love Python’ (1)
print(message[-1::-2]
True or False?
6 ‘The ‘else’ block in “try: except: else:” always executes.” (1)
What possible output(s) is expected from the following code?

import random
count=[‘ONE’, ’TWO’, ’THREE’, ‘FOUR’]
for k in range(3):
7 r=random.randint(k+1,3) (1)
print(count[r],end=’#’)

(A) ONE#TWO#THREE# (B) TWO#THREE#


(C) THREE#FOUR# (D) ONE#TWO#

Which of the following statement is False?

(A) list.pop() removes the last element of a list.


8 (B) list.remove(x) removes the element x from a list. (1)
(C) list.extend(l2) adds all the elements of list l2 to a list.
(D) list.sort() sorts all the elements of the list.

9 Which SQL command can display the cardinality of a table? (1)


Which of the following statement(s) would give an error after executing the
following code?
emp={‘Rajiv’:102, ‘Megan’:123,’Trevor’:128} #S1
print(emp[102]) #S2
10 (1)
emp[‘John’]=121 #S3
print(emp.pop()) #S4
(A) S1 (B) S2 (C) S3 (D) S2 and S4

In SQL, which clause is used to filter the rows returned by a query?


11 (A) WHERE (B) HAVING (C) SELECT (D) GROUP BY (1)

In Python, default arguments are assigned-

12 (A) From left to right (B) From right to left (1)


(C) In alphabetical order (D) Default arguments are not allowed
In Python, what is the use of the “is” keyword?

(A) To check for equality


13 (B) To check if two variables refer to the same object in memory (1)
(C) To define a class
(D) To declare a function

What is the output of the following code snippet?

def add(a, b=10):


14 (1)
return a + b
print(add(5))

(A) 5 (B) 10 (C) 15 (D) Error


What will be the output of the following code?
f = open("test.txt", "w")
f.write("Welcome")
f.seek(0)
f.write("Hi")
15 f.close() (1)
f = open("test.txt", "r")
print(f.read())
f.close()

(A) Hi (B) ComeHi (C) HiCome (D) Hiome

The SQL command ALTER TABLE is used to –

(A) Delete a table


16 (1)
(B) Modify the structure of an existing table
(C) Insert new rows into a table
(D) Drop an index

What is the purpose of the GROUP BY clause in SQL?


(A) To order the result set
17 (1)
(B) To group rows that have the same values in specified columns
(C) To filter rows based on a condition
(D) To delete rows from the table

What does DNS stand for in computer networking?


18 (A) Domain Network System (B) Digital Network Service (1)
(C) Domain Name System (D) Data Name Service

Which of the following is NOT an internet service provider (ISP)?


19 (1)
(A) Airtel (B) Jio (C) Google (D) BSNL

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): The PRIMARY KEY constraint ensures that each value in
20 a column is unique and not null. (1)
Reasoning (R): The PRIMARY KEY constraint allows duplicate values in
the column.

Assertion (A): A star topology is more reliable compared to a bus


21 topology. (1)
Reasoning (R): In star topology, failure of the central hub results in
network failure.
Q
Section-B (7 x 2=14 Marks) Marks
No

Explain the concept of a 'loop' in programming. How does a 'for loop' differ
22 (2)
from a 'while loop'?

(A) Define and differentiate between URL and domain name with the
help of an appropriate example
23 (2)
OR
(B) Differentiate between Switch and Gateway.

If L1=[1,2,3,5,8,11,12,15, . . . ], and L2=[10,20,30, . . .] are two lists, then:

Write a program to count the odd numbers in L1.


24 OR (2)
a) Write a statement to sort the elements of list L1 in descending order.
b) Write a statement to insert all the elements of L2 at the end of L1.
(Answer using builtin functions only)

Write an SQL query to retrieve all columns from a table named Students
where the Grade is 'A'.
25 (2)
OR
What is the purpose of the JOIN clause in SQL? Explain with a brief
example.
The following Python code is intended to calculate the sum of all even
numbers in a given list. Identify and correct the errors in the program.
Rewrite the correct program underlining all the corrections.
numbers = [1, 2, 3, 4, 5, 6, 7, 8]
sum even = 0
26 (2)
for num in numbers
if num % 2 = 0:
sum even += num

print "Sum of even numbers:", sum_even

Identify the correct output(s) of the following code. Also write the minimum
and the maximum possible values of the variable b.

import random

# Generate a list of 3 random numbers between 1 and 12


random_numbers = [random.randint(1, 12)%8+1 for _ in range(3)]
27 print("Random numbers:", random_numbers) (2)

(A) [1,8,9] (B) [2,7,4]


(C) [0,6,7] (D) [3,1,6]

# Find and print the maximum number in the list


b = max(random_numbers)
print("Maximum number:", b)
Write a user defined function in Python named showGrades (S) which
takes the dictionary Sas an argument. The dictionary, S contains Name:
[Eng, Math, Science] as key:value pairs. The function displays the
corresponding grade obtained by the students according to the following
grading rules-
Average of Eng, Math, Science Grade
>=90 A
<90 but >=60 B
28 <60 C (2)

For example: Consider the following dictionary


S={"AMIT": [92,86,64], "NAGMA": [65,42,43], "DAVID": [92,90,88]}
The output should be:
AMIT - B
NAGMA - C
DAVID – A

Q
Section-C (3 x 3 = 9 Marks) Marks
No

A dictionary, StudRec, contains the records of students in the following


pattern-
{admno: [m1, m2, m3, m4, m5]}

i.e., Admission No. (admno) as the key and 5 subject marks in the list as
the value.
Each of these records is nested together to form a nested dictionary.

Write the following user-defined functions in the Python code to perform


the specified operations on the stack named BRIGHT.

(i) Push_Bright(StudRec): it takes the nested dictionary as an


argument and pushes a list of dictionary objects or elements
29 containing data as {admno: total (sum of 5 subject marks)} into the (3)
stack named BRIGHT of those students with a total mark >350.
(ii) Pop_Bright(): It pops the dictionary objects from the stack and
displays them. Also, the function should display “Stack is Empty”
when there are no elements in the stack.
For Example: if the nested dictionary StudRec contains the following data:
StudRec={101:[80,90,80,70,90],102:[50,60,45,50,40],103:[90,90,99,98,90]}

Then Stack BRIGHT Should contain: [{101: 410}, {103: 467}]


The Output Should be:
{103: 467}
{101: 410}
If the stack BRIGHT is empty then display: Stack is Empty

30 Write a Python function that displays all the lines containing the word (3)
“excellent” from a text file “Myfile.txt”
OR
Write a Python function that find and displays all the words beginning with
‘w’ or ‘W’ from a text file “Paragraphs.txt”.

Predict the output of the Python code given below-

def fun_para(x=5,y=10,z=1005):
z=x/2
res=y//x+z
31 return res (3)
a,b,c=20,10,1509
print(fun_para(),fun_para(b),sep='#')
res=fun_para(10,20,6015)
print(res, "@")
print(fun_para(z=999,y=b,x=5), end="#@")
Q
Section-D (4 x 4 = 16 Marks) Marks
No
Consider the following table FACULTY.

A) Write the following queries:


32 (4)
(i) To display the Salary of each Faculty, excluding those with salary
less than 12000.
(ii) To display all of the records sorted by Hire_date in descending
order.
(iii) To display all the Fname from the table without repetition.
(iv) Write a query to increase the salary of all the employees by 10%.

OR
B) Write the output of:
(i) Select * from FACULTY where salary > 12000;
(ii) Select Fname from FACULTY WHERE Hire_date between 01-01-
2000 and 31-12-2006;
(iii) Select AVG(SALARY) from FACULTY;
(iv) Select * from FACULTY where Fname like “R%”;

A csv file “HappyBank.csv” contains the details of Employees like:


• EmpID
• EmpName
33 (4)
• Desig
• Dept
Write the following Python functions to perform the specified operations on
this file:

i) Write the header row and records of five employees into the file.
ii) Appends a new record in the CSV file.

Consider the tables PRODUCT and BRAND given below:

34 (4)

Write SQL queries for the following-


(i) Display product name and brand name from the tables PRODUCT
and BRAND.
(ii) Display the structure of the table PRODUCT.
(iii) Display the average rating of Medimix and Dove brands
(iv) Display the name, price, and rating of products in descending order
of rating.
Kabir wants to write a program in Python to insert the following record in
the table named ‘Student’ in MYSQL database, ‘SCHOOL’ -
• rno(Roll number )- integer
• name(Name) - string
• DOB (Date of birth) – Date
• Fee – float
35 Note the following to establish connectivity between Python and MySQL: (4)
• Username - root
• Password - tiger
• Host - localhost
The values of fields rno, name, DOB and fee has to be accepted from the
user. Help Kabir to write the program in Python.
Q
Section-E ( 5 x 2 = 10 Marks) Marks
No
Manoj is working in a sports college. He needs to manage the records of
the teams in each Sport. For this, he wants the following information of the
36 (5)
students to be stored in the binary file SPORT.DAT-
• SportName
• TeamName
• No_Players
You, as a programmer of the company, have been assigned to do this job
for the college.
i) Create the binary file SPORT.DAT
ii) Write a function AddTeam to input the details and add a record to
the file.
iii) Write a function, copyData(), that reads contents from the file
SPORT.DAT and copies the records with Sport name as “Basket
Ball” to the file named BASKET.DAT. The function should also
return the total number of records copied to the file BASKET.DAT.
MyPace University is setting up its academic blocks at Naya Raipur and is
planning to set up a network. The University has 3 academic blocks and
one Human Resource Centre as shown in the diagram below.

Distances between various blocks/centre are as follows-

Law Block to business Block 40m


Law block to Technology Block 80m
Law Block to HR Center 105m
Business Block to technology Block 30m
Business Block to HR Center 35m
37 Technology block to HR Center 15m (5)

Number of computers in each of the blocks/Center is as follows-

Law Block 15
Technology Block 40
HR Center 115
Business Block 25

a) Suggest the most suitable place (i.e., Block/Center) to install the


server of this University with a suitable reason.
b) Suggest an ideal wired layout for connecting these blocks/centers.
c) Which device will you suggest to be placed/installed in each of these
blocks/centers to efficiently connect all the computers within these
blocks/centers?
d) Suggest the placement of a repeater in the network with justification.
e) The university is planning to connect its admission office in Delhi,
which is more than 1250 km from university. Which type of network out
of LAN, MAN, or WAN will be formed? Justify your answer.

*** ALL THE BEST ***

You might also like