CS Set 2
CS Set 2
General Instruction:
• 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.
a. 'Hello' c. 'World@2024'
b. ['Hello'] d. ['World@2024']
Page 1 of 10
6. Given the following dictionaries:
dict_fruit={"Kiwi":"Brown", "Cherry":"Red"}
dict_vegetable={"Tomato":"Red", "Brinjal":"Purple"}
Which statement will merge the contents of both dictionaries?
a. dict_fruit.update(dict_vegetable) c. dict_fruit.add(dict_vegetable)
b. dict_fruit + dict_vegetable d. dict_fruit.merge(dict_vegetable)
7. What will be the output of the following Python code?
8. fetchone() method fetches only one row in a ResultSet and returns a __________.
a. Tuple b. List c. String d. Dictionary
9. A resultset is extracted from the database using the cursor object (that has been already created) by
giving the following statement. Mydata=cursor.fetchone()
a. How many records will be returned by fetchone() method?
b. What will be the datatype of Mydata object after the given command is executed?
10. CSV files are opened with __________argument to supress EOL translation.
a. delimiter b. writer c. newline d. next
11. In a try-except block with multiple except blocks, which block will be executed if an
exception matches multiple except blocks.
a. The first matching except block encountered from top to bottom
b. All matching except blocks simultaneously
c. The last matching except block encountered from top to bottom
d. None of the above
12. Which is the correct output for the following code?
a. 40#1200@
b. 30#610@
c. -10#-10@
d. ZeroDivisionError: integer division or modulo by zero
Page 2 of 10
13. Identify the SQL command to delete a relation from a relational database.
a. DROP TABLE c. DELETE TABLE
b. REMOVE TABLE d. ERASE TABLE
14. Sonal needs to display name of teachers, who have “O” as the third character in their name. She wrote
the following query. SELECT NAME FROM TEACHER WHERE NAME = “%O%”; But the query
isn’t producing the result. Rewrite the correct query.
15. _______ is the table constraint used to stop null values to be entered in the field.
a. Unique c. default
b. Not NULL d. Foreign Key
16. Which of the following types of table constraints will prevent the printing of duplicate values after
the Select statement fetches data from table?
a. Unique c. Primary Key
b. Distinct d. NULL
17. In which of the network topologies do all devices connect to a central point, such as a switch or hub?
a. Star b. Bus c. Tree d. Ring
18. Every network interface card(NIC) comes with its own__________address.
a. IP Address c. MAC Address
b. DHCP Address d. Ethernet card number
19. Which protocol out of the following is used for accessing and downloading emails from a remote
server to a local client?
a. POP3 b. IMAP c. HTTP d. SMTP
Q-20 and Q-21 are Assertion (A) and Reason (R) Type questions. Choose the correct option as:
A. Both Assertion (A) and Reason (R) are true, and Reason (R) is the correct explanation of Assertion
B. Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion.
C. Assertion (A) is True, but Reason (R) is False
D. Assertion (A) is False, but Reason (R) is True
20. Assertion (A): In Binary Files, no specific encoding scheme; the interpretation of bytes depends on
the file format.
Reason (R): Python objects (list, dictionary etc) have a specific structure which must be maintained
while storing or accessing them. Python provides a special module called pickle module for this.
21. Assertion (A): In SQL, INSERT INTO is a Data Definition Language (DDL) Command.
Reason (R): DDL commands are used to create, modify, or remove database structures, such as
tables.
Page 3 of 10
SECTION B (7 x 2 =14)
22. Explain the difference between setdefault and update function with an example with respect to
dictionary
23. Consider the following code:
my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
What will be the output of the following python statement?
a. list(my_dict) b. '*'.join(my_dict)
24. Name the BUILT-IN functions/methods used in the following scenario:
a. The Mathematical function/method that returns the largest integer less than or equal to a given number
OR
Name the string function that returns the index value of the first occurrence of the character in the
string and returns -1 if the character is not present.
b. Name the function in statistics module that returns the most frequently occurring value in a list or
dataset.
OR
Name the function in statistics module that calculates the arithmetic average.
25. What possible output(s) are expected to be displayed on screen at the time of execution of the program
from the following code? Also specify the maximum values that can be assigned to each of the
variables BEGIN and LAST.
Page 4 of 10
27. Explain the use of ‘Foreign Key’ in a Relational Database. Give an example to support your answer.
OR
What do you mean by aliasing with respect to SQL? Give a suitable example for the same.
28. i) Expand the following:
a. SMTP b. VoIP
ii) Write any one difference between HTML and XML.
OR
Write any two differences between Fiber-optic cable and Coaxial cable.
SECTION C ( 3 x 3 =9 )
29. Write the definition of a python function longlines() which reads the contents of a text file ‘Lines.txt’
and displays those lines from the file which have at least 10 words in it.
For example, if the content of ‘Lines.txt’
Once upon a time, there was a woodcutter
He lived in a little house in a beautiful, green wood.
One day, he was merrily chopping some woods.
He saw a little girl skipping through the woods, whistling happily.
The girl was followed by a big grey wolf.
The function should display the output as:
He lived in a little house in a beautiful, green wood.
He saw a little girl skipping through the woods, whistling happily.
OR
Write the definition of a python function CountT() which reads the contents of a text file named ‘Lines.txt’
and displays those lines from the file which have minimum two words starting with ‘t’ or ‘T’
For example, if the content of ‘Lines.txt’
Once upon a time, there was a woodcutter
He lived in a little house in a beautiful, green wood.
One day, he was merrily chopping some woods.
He saw a little girl skipping through the woods, whistling happily.
The girl was followed by a big grey wolf.
The function should display the output as:
Once upon a time, there was a woodcutter
He saw a little girl skipping through the woods, whistling happily.
30. A dictionary, StudRec, contains the records of students in the following pattern:
Page 5 of 10
{admno: [m1, m2, m3, m4, m5]}, i.e., Admission No. (admno) as the key and 5 subject
marks in list as the value. Write the following user-defined functions to perform the specified operations
on the stack named BRIGHT.
(i) Push_Bright(StudRec): it takes the dictionary as an argument and pushes the admno of the dictionary
into the stack named BRIGHT of those students with a total mark >350.
For Example: if the 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]}
Thes Stack BRIGHT Should contain: [101,103]
(ii) Pop_Bright(): It pops all the element from the stack and displays them. Also, the
function should display “Bright is Empty” when there are no elements in the stack.
The Output Should be:
103
101
Bright is Empty
OR
A list, NList contains following record as list elements: [City, Country, distance from Delhi] Each of these
records are nested together to form a nested list. Write the following user-defined functions to perform the
specified operations on the stack named travel.
(i) Push_element(NList): It takes the nested list as an argument and pushes a list object containing name
of the city and country, which are not in India and distance is less than 3500 km from Delhi.
For example: If the nested list contains the following data:
NList=[ ["New York", "U.S.A.", 11734], ["Naypyidaw", "Myanmar", 3219],
["Dubai", "UAE", 2194], ["London", "England", 6693],
["Gangtok", "India", 1580], ["Columbo", "Sri Lanka", 3405] ]
The stack should contain:
['Naypyidaw', 'Myanmar']
['Dubai', 'UAE']
['Columbo', 'Sri Lanka']
(ii) Pop_element(): The function should pop all the elements from the stack and displays them. Also, the
function should display “Stack Empty” when there are no elements in the stack.
The output should be:
['Columbo', 'Sri Lanka']
['Dubai', 'UAE']
['Naypyidaw', 'Myanmar']
Stack Empty
Page 6 of 10
31. Predict the output
OR
SECTION D ( 4 x 4 =16 )
32. Consider the following table DOCTOR as given below:
Page 7 of 10
b. Write the output for the following queries:
i. SELECT D_NAME, GENDER from DOCTOR WHERE EXPERIENCE = 6 AND GENDER !=
‘MALE’
ii. SELECT GENDER,MIN(EXPERIENCE) FROM DOCTOR GROUP BY GENDER;
iii. SELECT COUNT(DISTINCT D_DEPT) FROM DOCTOR;
iv. SELECT D_NAME, EXPERIENCE FROM DOCTOR WHERE NOT D_DEPT IN
('ORTHO','ENT');
33. Vijay has created a CSV file FOOTBALL.CSV to store player details, like player name, matches
played, and goals scored. The file has the following columns as headers: [PNAME, MATCH,
GOALS].
The data type of
PNAME – str MATCHES- int GOALS- int
Write the following user-defined functions in Python:
i. addPlayer(name, matches, goals): This function takes three parameters. It should create a list
containing these details and append the data to the existing CSV file FOOTBALL.CSV without
overwriting previous entries.
ii. HighestAverage(): This function reads FOOTBALL.CSV and displays the name of the player with
the highest average goals per match (i.e., goals/matches). Ensure that the function does not calculate
average where matches might be zero.
34. Consider the following tables PRODUCT and CLIENT given below:
TABLE : PRODUCT
Page 8 of 10
TABLE : CLIENT
i. Query to display the PR_ID, PR_Name and C_Name from product and client table whose manufactures
are either FIAMA OR COLGATE.
ii. Query to display the details of those PRODUCTS whose client city is DELHI.
iii. Query to display the manufacturer and Price x Qty as Total for the manufacturer’s whose name ends
with ‘E’
iv. Query to add a column called Discount (Int Data type) in the Product table.
OR
Query to remove the record from product table whose qty is less than 15.
35. Shanaiya wants to write a python program which calls the python function runs_scored(run) in python
to display the record according to descending order of player names whose runs scored are more than
the runs entered by the user(passed as parameter in the function) from the cricket table of sports
database. The MySQL server is running on LocalHost and the login credentials are as follows:
Username: Shanaiya
Password: happy
The columns of the CRICKET table are as follows
pid(Player ID) -integer
pname(Player name) -string
runs (Runs scored) – integer
wickets (Wicket taken) – integer
Page 9 of 10
TotalVote is total vote received by the candidate
For efficiently maintaining data of the event, Deepak wants to write the following user defined
functions:
• accept() – to accept a record from the user and add it to the file Election.bin
• Search(PartyName) – to display the record for a particular person name and send the appropriate
message if such record does not exist.
• update() – To update the Candidate name and Total votes based on the Party_ID.
As a Python expert, help him complete the task.
37. CITY CABLE NETWORK has set up its new centre at DELHI, it has four buildings as shown in the
diagram given below:
As a network expert, provide the best possible answer for the following queries:
i. Suggest the most suitable place to install the server with suitable reason.
ii. Suggest the most suitable cable layout for the above network.
iii. Name the device used to connect the computers in the block.
iv. Which hardware/ software device will you suggest being procured by the company to be installed to protect
and control the internet uses within the campus.
v. The System Administrator does remote login to any PC, if any requirement arises. Name the protocol, which
is used for the same.
OR
Name the protocols used to send and receive emails between Delhi and Dubai office.
Page 10 of 10