Skip to content

Class XII – Computer Science – Paper – 2

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

1. State True or False

Digits are one of the parts of the Python character set

View Answer

Ans. True


2. Which command is used to modify or change existing records in a table?

(a) UPDATE

(b) CHANGE

(c) ALTER

(d) MODIFY

View Answer

Ans. (a) UPDATE


3. Which of the following operator cannot be used with string data type?

(a) +

(b) in

(c) *

(d) /

View Answer

Ans. (d) /


4. Which of the following is a category of SQL commands?

(a) DDL

(b) TCL

(c) DML

(d) All of these

View Answer

Ans. (d) All of these


5. What is the output of the following code? num = 5 + float(9) / int(3.0) print(“num =”, num)

(a) num = 8.0

(b) 7.5

(c) num : 6.5

(d) Error

View Answer

Ans. (a) num = 8.0


6. What will be the output of the following code snippet?

text = “Data Structures”

print(text[5:15:3])

View Answer

Ans. tcs


7. Given : s= “ComputerExam”.

What will be the output of print(s[2]+s[8]+s[1:5)?

(a) mEOMUU

(b) mEompu

(c) mEomPU

(d) MEompu

View Answer

Ans. (b) mEompu


8. The clause to arrange the data of a column in descending order is

(a) DESC

(b) GROUP BY

(c) LIKE

(d) ASC

View Answer

Ans. (a) DESC


9. Which of the following is the most common type of constant?

(a) Keywords

(b) Literals

(c) Variables

(d) Identifiers

View Answer

Ans. (b) Literals


10. Complete the following code snippet with the appropriate statement:

file = open(“report.txt”, “r”)

content = file.read(50)

file.seek(-10, 1)

remaining_content = file.read()

file.close()

View Answer

Ans. file.seek(-10, 1)


11. State whether the following statement is True or False:

The `finally` block in Python executes whether or not an exception occurs in the `try` block.

View Answer

Ans. True


12. Which of the following types of files will need the pickle module for working on it ?

(a) Binary files

(b) Text files

(c) CSV files

(d) All of these

View Answer

Ans. (a) Binary files


13. In the following code, which lines will give error? (Assume the lines are numbered starting from 1.)

mul=3

value=10

for i in range (1, 6, 1):

if (value % mul = 0):

print (value * multiply)

else

print (value + multiply)

(a) 4,5

(b) 4,5,6

(c) 4,5,6,7

(d) No errors

View Answer

Ans. (c) 4,5,6,7


14. A relation can contain ____ foreign keys.

(a) 2

(b) 3

(c) 1

(d) Multiple

View Answer

Ans. (d) Multiple


15. The_____clause with the COUNT() function counts only the unique values in an attribute.

(a) UNIQUE

(b) HAVING

(c) DISTINCT

(d) LIKE

View Answer

Ans. (c) DISTINCT


16. Python scripts can be written to connect with MySQL using which of the following libraries?

(a) MySQL.connector library

(b) SQL.connect library

(c) MySQL.connect library

(d) None of these

View Answer

Ans. (a) MySQL.connector library


17. Which protocol is used for remote login?

(a) HTIT

(b) PPP

(c) IRCP

(d) Telnet

View Answer

Ans. (d) Telnet


18. Which of the following functions will read lines of a text file as list elements.

(a) read( )

(b) get()

(c) readline( )

(d) readlines( )

View Answer

Ans. (d) readlines( )


19. Which of the following will be the output of the statement given below?

print([12,34,56,78,90].pop())

(a) 78

(b) 90

(c) 12

(d) 12,34,56,78,90

View Answer

Ans. (b) 90


Direction (Q.Nos. 20-21) are Assertion and Reason based questions.

20. Assertion (A) : In a cross join the number of records in the output will be the maximum.

Reason (R) : A cross join is also called a Cartesian product.

(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.

View Answer

Ans. (b) Both A and R are true but R is not the correct explanation for A.


21. Assertion (A) : A file that is opened using the open() function may not specify the mode of opening it.

Reason (R) : If the mode is not specified , the read mode is used by default..

(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.

View Answer

Ans. (b) Both A and R are true but R is not the correct explanation for A.


SECTION B

22. Observe the given list and find the answer of questions that follows.

list1 = [23, 45, 63, ‘Hello’, 20

‘World’, 15, 18]

(i) list1[–3]

(ii) list1[3] View Answer

Ans. (i) ‘World’

(ii) ‘Hello’


23. (a) Find the output

L = [15, 28, 55, 88, 15, 33, 5]

(i) L[2:6]

(ii) L[::-3] View Answer

Ans. [55, 88, 15, 33]

[5, 88, 28]


(b) Find the error(s).

L1 = [7, 2, 3, 4]

L2 = L1 + 2

L3 = L1 * 2

L = L1.pop(7)

View Answer

Ans. Error 1 L2 = L1 + 2 because + operator cannot add list with other type as number or string

Error 2 L = L1.pop(7) parentheses puts index value instead of element. In the given list, maximum index value is 3 and 7 is out of index range.


24. What is the advantage of using switch over hub?

View Answer

Ans. Switch provides a dedicated line at full bandwidth between two devices but hub doesn’t provide a dedicated line. Hub share the bandwidth.


OR

Write some benefits of networking.

View Answer

Ans. Some of the benefits of networking are

(i) File sharing

(ii) Hardware sharing

(iii) Application sharing

(iv) User communication

(v) Access to remote database


25. What do you understand by RDMS?

View Answer

Ans. A Relational Database Management System (RDBMS) is a database management system. It is developed by Dr. E.F. Codd, of IBM’s SAN Jose Research Laboratory.


26. (a) Write the full forms of :

(i) POP

View Answer

Ans. Post Office Protocol


(ii) HTTP

View Answer

Ans. HyperText Transfer Protocol


(b) Differentiate between the terms Internet and Intranet.

View Answer

Ans.


27. What will be the output of the following code?

dic = {‘a’:1, ‘b’:2, ‘c’:3, ‘d’:4}

print(dic)

if ‘a’ in dic :

del dic[‘a’]

print(dic)

View Answer

Ans. {‘d’: 4, ‘a’: 1, ‘c’: 3, ‘b’: 2}

{‘d’ : 4, ‘c’ : 3. ‘b’ : 2}


OR

Distinguish between tuple and list.

View Answer

Ans.


28. Describe the concept of candidate keys and provide a suitable example to illustrate.

View Answer

Ans. A candidate key is a set of one or more fields that identifies each record uniquely in a table. There can be multiple candidate keys in one table and one of them will become the primary key.


e.g.

In the Item table, INO and IName can be treated as the candidate keys.

[/expand]

OR

Observe the following table carefully and write the names of the most appropriate columns, which can be considered as (i) candidate keys and (ii) primary key.

View Answer

Ans. (i) Candidate Keys CID, ITEM

(ii) Primary key CID


SECTION C

29. Write Push(contents) and Pop() methods in Python to add and remove numbers, simulating stack operations.

View Answer

Ans.


OR

Find the final contents of a stack on which the following operations are done.

1. Push(100)

2. Push(200)

3. Push(50)

4. Push(50)

5. Pop()

6. Push()

7. Pop(2)

8. Pop()

View Answer

Ans.


30. The binary file “emp.dat” contains employee records with the following structure:

Eno        Ename                  Salary

1             Mr. Raj                 85000

: Write a Python program to open “emp.dat” and display only the records where the employee’s salary exceeds 75000.

View Answer

Ans.


OR

Write a program to read the content from a text file “status.txt”, count and display the total number of lines and blank spaces present in it. e.g. if the “status.txt” file contains the following lines:

Welcome to your one-step solutions for all your study, practice and assessment needs for various competitive & recruitment examinations and school segment. We have been working tirelessly for over a decade to make sure that you have best in class study resources because you deserve SUCCESS AND NOTHING LESS…

The output will be:

The status file contents are

Total lines in file are: 4

Total spaces in file are: 43

View Answer

Ans.


31. The code given below reads a text file and displays those words that begin with an uppercase vowel and end with a lowercase vowel. Some of the codes are missing. Write codes to fill up the blanks.

f=open(“emp.txt”)

filedata=f.read()

count=0

print(filedata)

data=filedata.split(‘ ’)

for………. in data : #Blank1

if words[–1] in “aeiou” and …in “AEIOU”: # Blank2

print(……… .) # Blank3

f.close()

(i) Write the missing code for Blank1.

View Answer

Ans. words


(ii) Write the missing code for Blank2.

View Answer

Ans. words[0]


(iii) Write the missing code for Blank3.

View Answer

Ans. words


OR

Write a user defined function change(L) to accept a list of numbers and replace the numbers in the list with their sum of digits.

Example

Input : [32,142,215,26,7]

Output : [5, 7 , 8 , 8, 8,7] View Answer

Ans.


SECTION D

32. (a) Underline the syntax errors in the following program

x = int(input(“Enter first number:))

y = int(input(“Enter second number:”))

z = int(input(“Enter third number:”)

a = x+ b+ z

print (“Result = ”, b)

View Answer

Ans.


(b) Write the code to create the following table Student with the following fields

RollNo

FirstName

LastName

Address

ContactNo

Marks

Course

Rank

In the table, Rank should be Good, Best, Bad, Worst, Average.

View Answer

Ans.


OR

(a) Differentiate between a logical error and syntax error. Also, give suitable examples of each in Python.

View Answer

Ans.


(b) What is the use of fetchone() method? Write an example code to fetch a single record from a database.

Note :

Database : PythonDB

Table : Student

Host : localhost

UsedlD : root

Password : arahant

View Answer

Ans. fetchone() returns the next row from the result set as tuple. If there are no more rows to retrieve, None is returned.

e.g. To fetch only one record


33. Which module is used to operate on CSV file?

Write a python program with following functions :

(a) addcsv():

File old.csv has come from branch in Pune and it needs to be added to file “updated.csv” which has data for all branches. Write the code in the function to perform the same.

(b) convertcsv() :

A file old.csv has come with separator ‘:’ but your system can only read ‘;’ Write a program to convert to “converted.csv” file. Write the function to change the separator of the file.

View Answer

Ans. To read and write in CSV files we need to import csv module.

Program:


34. (a) Consider the tables Travel and Train given below

Write the command to display the passenger names and the train names by which they are travelling for all passengers travelling by “Mail” trains.

View Answer

Ans. SELECT Tr.Pname, T.Tname FROM Travel Tr, Train R WHERE Tr.TId = T.TId AND Tname LIKE “%Mail”;


(b) Considering the tables Train and Travel given above write commands for the following :

(i) Display passenger names , corresponding train names and amounts for records where amount >5000.

View Answer

Ans. SELECT T1.Pname, T2.Tname, T1.Amt FROM Travel T1, Train T2 WHERE T1.TId = T2.TId AND Amt > 5000;


(ii) Increase amount of passengers by 20% who are travelling by ‘AC”

View Answer

Ans. UPDATE Travel SET Amt = Amt+Amt*0.2 WHERE Class = “AC”;


(iii) Display a cross join of the two tables.

View Answer

Ans. SELECT * FROM Travel, Train;


OR

(iv) Remove records of passengers who are travelling by “Rajdhani”.

View Answer

Ans. DELETE FROM Travel Tr, Train T WHERE Tr. TId = T-TId AND T.Tname=”Rajdhani”;


35. Consider the following tables SENDER and RECIPINT. Write SQL commands for the statements (i) to (iv).

(i) To display the names of all Senders from Mumbai.

View Answer

Ans. SELECT SenderName FROM SENDER WHERE SenderCity =’Mumbai’;


(ii) To display the RecID, SenderName, SenderAddress, RecName, RecAddress for every Recipient.

View Answer

Ans. SELECT RecID, SenderName, SenderAddress, RecName, RecAddress FROM RECIPIENT, SENDER WHERE RECIPEINT.SenderOD = SENDER.SenderID;


(iii) To display Recipient details in ascending order of RecName.

View Answer

Ans. SELECT * FROM RECIPEIENT ORDER BY RecName;


(iv) To display number of Recipients from each City.

View Answer

Ans. SELECT COUNT (*) AS “No of Recipients”, RecCity from RECIPIENT GROUP BY RecCity;


SECTION E

36. Freshminds University of India is launching its first campus in Ana Nagar, South India, with a central admissions office in Kolkata. The campus spans 5 km and consists of three main blocks: Office, Science, and Commerce.

As a network expert, propose a network plan addressing points (i) to (v), considering the given distances and parameters.

Expected wire distance between various locations.

Expected number of computers to be installed at various locations in the university are as follows:

(i) Suggest the authorities, the cable layout amongst various blocks inside university campus for connecting the blocks.

View Answer

Ans.


(ii) Suggest the most suitable place (i.e. block) to house the server for this university with a suitable reason.

View Answer

Ans. The most suitable place to house the server is Science Block as it has maximum number of computers. Thus, reducing the cabling cost and increases efficiency of network.


(iii) Suggest an efficient device from the following to be installed in each of the block to connect all the computers.

(a) Modem

(b) Switch

(c) Gateway

View Answer

Ans. Ans. Switch is the device to be installed in each of the blocks to connect all the computers.


(iv) Suggest a suitable topology to connect the computers in each building.

View Answer

Ans. Star topology, as it is the best in efficiency.


(v) University is planning to connect its campus in Kolkata which is more than 100 km. Which type of network will be formed?

View Answer

Ans. WAN (Wide Area Network) will be formed.


37. Consider the following table Person

(i) What should be the constraint(s) of the P_Id column?

View Answer

Ans. Primary key


(ii) If 3 columns are added to the table , what will be its degree?

View Answer

Ans. 8, There are 5 columns + = 8 columns.

Degree is number of columns.


(iii) Write statements to :

(a) Display the Unique Cities.

View Answer

Ans. SELECT DISTINCT City FROM Person;


(b) Display Firstnames of people who do not have a address.

View Answer

Ans. SELECT FirstName FROM Person WHERE address IS NULL;


OR (Option for part (iii) only)

Write appropriate data types to store the following :

(a) Amounts carrying values with decimal.

View Answer

Ans. float/decimal/double


(b) Joining dates.

View Answer

Ans. date/date time