CS Academy
Computer Science – 083
Half Yearly Examination – 2024-25
Grade XII – G
Answer Key
SECTION A 18*1=18
1. b) \\\
2. b) MENE
3. 42
4. ext#nex
5.Alter
6. b) ("","MA","LAYALAM")
7. c) None
8. puC dlroW
9. c. Error
10. Observe the following code carefully and rewrite it after removing all syntactical errors. Underline all the
corrections made.
11. (c) None
12. 30 60
10
13. where
14. (a) fp.seek(offset,0)
15. Binary Files
16. 70
17. (b) Both (A) and (R) are true and (R) is not the correct explanation for (A).
18. (a) Both (A) and (R) are true and (R) is the correct explanation for (A).
SECTION B 7*2=14
19. (i) Write the advantage and disadvantage of Tree Topology.
Advantages of Tree Topology :
This topology is the combination of bus and star topology.
This topology provides a hierarchical as well as central data arrangement of the nodes.
Disadvantages of Tree Topology :
This network is very difficult to configure as compared to the other network topologies.
The length of a segment is limited & the limit of the segment depends on the type of cabling used.
(ii) Differentiate between XML and HTML.
XML HTML
The full form is eXtensible Markup Language The full form is Hypertext Markup Language
The main purpose is to focus on the transport Focusses on the appearance of data.
of data and saving the data Enhances the appearance of text
XML is dynamic because it is used in the HTML is static because its main function is in
transport of data the display of data
20. ['Fifth', 'fourth', 'third', 'second']
21. 39 14
24 25
22. DEL@COL@BEI
23. (i) 1st.remove(10)
(ii) str1 = str1.replace("This", "That")
24. DELETE FROM student WHERE Stud_id = 100;
INSERT INTO student (Stud_id, Name, Class, Stream) VALUES (123, 'Rajeev', 12,
'Science');
25. 6$30
SECTION C 5*3=15
26. gIDIA@ GroIiG
27. Consider the table Stationery given below and write the output of the SQL queries that follow.
(i) SELECT DISTRIBUTOR, SUM(QTY) FROM STATIONERY GROUP BY DISTRIBUTOR;
Distributor Sum(qty)
Reliable stationers 100
classic Plastics 400
Clear Deals 410
(ii) SELECT ITEMNO, ITEM FROM STATIONERY WHERE DISTRIBUTOR = "Classic Plastics" AND PRICE > 10;
ItemNo Item
402 Gel pen premium
406 Gel pen classic
(iii) SELCET ITEM, QTY * PRICE AS "AMOUNT" FROM STATIONERY WHERE ITEMNO = 402;
Item Amount
Gel pen premium 3000
28. Write a method/function DISPLAYLINES() in Python to read lines from a text file CONTENT.TXT, and display those
lines, which have @ anywhere in the line.
29. Consider the table Rent_cab, given below :
Based on the given table, write SQL queries for the following :
(i) Add a primary key to a column name Vcode.
alter table rent_cab add primarykey(vcode);
(ii) Increase the charges of all the cabs by 10%.
update rent_cab set charges=charges+charges*0.1;
(iii) Delete all the cabs whose maker name is "Carus".
delete from rent_cab where make=”carus”;
30. A dictionary, d_city contains the records in the following format : {state:city}
Define the following functions with the given specifications :
(i) push_city(d_city): It takes the dictionary as an argument and pushes all the cities in the stack CITY whose states
are of more than 4 characters.
(ii) pop_city(): This function pops the cities and displays "Stack empty" when there are no more cities in the stack.
SECTION D 2*4=8
31. Consider the tables GAMES and PLAYERS given below :
Write SQL queries for the following :
(i) Display the game type and average number of games played in each type.
select type,avg(number) from games groupby type;
(ii) Display prize money, name of the game, and name of the players from the tables Games and Players.
select prizemoney,gamename,name from games g,player p whereg.gcode=p.gcode;
(iii) Display the types of games without repetition.
select distinct type from games;
(iv) Display the name of the game and prize money of those games whose prize money is known.
select gamename,prizemoney from games where prizemoney is not null;
32. Mr. Mahesh is a Python Programmer working in a school. He has to maintain the records of the sports students.
He has created a csv file named sports.csv, to store the details. The structure of sports.csv is : [sport_id, competition,
prize_won] where
sport_id, is Sport id (integer)
competition is competition name (string)
prize_won is (“Gold”, “Silver”, “Bronze”)
Mr. Mahesh wants to write the following user-defined functions :
Add_detail(): to accept the detail of a student and add to a csv file, "sports.csv".
Count_Medal(): to display the name of competitions in which students have won "Gold" medal. Help him in writing
the code of both the functions.
SECTION E 3*5=15
33. Logistic Technologies Ltd. is a Delhi based organization which is expanding its office set-up to Ambala. At Ambala
office campus, they are planning to have 3 different blocks for HR, Accounts and Logistics related work. Each block
has a number of computers, which are required to be connected to a network for communication, data and resource
sharing.
As a network consultant, you have to suggest the best network related solutions for them for issues/problems raised
in (i) to (v), keeping in mind the distances between various block/locations and other given parameters.
Distances between various blocks/locations :
(i) Suggest the most appropriate block/location to house the SERVER in the Ambala office. Justify your answer.
HR BLOCK
(ii) Suggest the best wired medium to efficiently connect various blocks within the Ambala office compound.
Twisted Pair Cable
(iii) Draw an ideal cable layout (Block to Block) for connecting these blocks for wired connectivity.
HR BLOCK------------------Account Block----------------Logistics Block
(iv) The company wants to schedule an online conference between the managers of Delhi and Ambala offices. Which
protocol will be used for effective voice communication over the Internet ?
VOIP
(v) Which kind of network will it be between Delhi office and Ambala office ?
WAN
34. (i) Give one difference between write() and writeline() function in text file.
The `Write` method is used to write text to the console without adding a newline character at the
end of the text. The `WriteLine` method is used to write text to the console and adds a newline
character at the end of the text, causing the next output to appear on a new line.
(ii) Consider a binary file, Cinema.dat containing information in the following structure :
[Mno, Mname, Mtype]
Write a function, search_copy(), that reads the content from the file Cinema.dat and copies all the details of the
"Comedy" movie type to file named movie.dat.
def search_copy():
with open('cinema.dat', 'r') as source_file, open('movie.dat', 'w') as dest_file:
for line in source_file:
parts = line.strip().split(', ')
if len(parts) == 3 and parts[2] == 'Comedy':
dest_file.write(line)
35. (i) Give one difference between CHAR and VARCHAR datatype in MySQL.
The fundamental difference between CHAR and VARCHAR is that the CHAR data type is fixed in length, while
the VARCHAR data type supports variable-length columns of data. But they are also similar. They both can
store alphanumeric data
(ii) Rahim wants to write a program in Python to insert the following record in the table named Bank_Account in
MySQL database,
Bank : · Accno – integer
· Cname – string
· Atype – string
· Amount – float
Note the following to establish connectivity between Python and MySQL :
· Username – admin
· Password – root
· Host – localhost
The values of fields Accno, Cname, Atype and Amount have to be accepted from the user. Help Rahim to write the
program in Python.