You are on page 1of 9

PRACTICE PAPER–2

CLASS XII
COMPUTER SCIENCE (083)
Time Allowed: 3 hrs Maximum Marks: 70

General Instructions:
• This question paper contains 35 questions.
• The paper is divided into 5 Sections—A, B, C, D and E.
• Section A consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D consists of 2 questions (31 and 32). Each question carries 4 Marks.
• Section E consists of 3 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python language only.

SECTION A
1. By default, a Python file is saved with ________ extension. (1)
(a) .py (b) .pyc
(c) . pyw (d) All of these
2. A table ‘Student’ contains 4 rows and 6 columns, whereas a table 'Result' contains 8 rows and 3 columns.
What will be the cardinality and degree of the resultant table after applying the Cartesian product to the
given tables? (1)
(a) 12,9 (b) 32,18
(c) 32,9 (d) 9,32
3. What will be the output of following code: (1)
print("Hello", "Rahul!","Good Evening", sep="#", end="$$")
print("\nAll is well", "enjoy your day")
print("Take care!","See you soon",sep=",")
(a) Hello#Rahul!Good Evening$$
All is well
enjoy your day
(b) Take care!See you soon,
HelloRahul!#Good$$Evening
All is well enjoy your day
Take care!,
See you soon
(c) Error
(d) Hello#Rahul!#Good Evening$$
All is well enjoy your day
Take care!,See you soon
4. What will be the output of the following code if the input(x) is 3? (1)
if x < 1 :
print("invalid value")
else :
for a in range(1,x+1) :
print( a * a)

Practice Paper–2 1
(a) 149 (b) 1
4
9
(c) invalid value (d) 3
4
5
5. Fill in the blank:
__________ command is used to delete all the rows from a table and free the space containing the table
for reuse. (1)
(a) DELETE (b) REMOVE
(c) DROP (d) TRUNCATE
6. Which device can handle different protocols in a network? (1)
(a) Gateway (b) Bridge
(c) Router (d) None of these
7. If t = (25,36,47,58), which of the following statements is false? (1)
(a) t[2]=45 (b) t[: : -1]
(c) print(min(t)) (d) print(len(t))
8. What is the output of following codes: (1)
m = "Sustainable"
n = "Development"
s = m[:1]+n[len(n)-1:]
print(s)
(a) S (b) Sn
(c) SD (d) St
9. What possible output is 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 min
and max. (1)
import random
l = [200,300,400,500,600,700]
min = random.randint(1,3)
max = random.randint(2,4)
for i in range (min, max +1):
print (l[i], end = “@”)
(a) 100@400@700@ (b) 300@400@500@
(c) 500@600@700@ (d) 400@500@700@
10. What will be the output of the following? (1)
list = ['ab', 'cd']
for j in list[0:len(list)]:
list.append(j.upper())
print(list)
(a) ['AB', 'CD'] (b) ['ab', 'cd', 'AB', 'CD']
(c) ['ab', 'cd'] (d) None of these

2 Practice Paper–2
11. Which of the following network devices is connected to both source and destination computers? (1)
(a) Bridge (b) Switch
(c) Gateway (d) Modem
12. What is the output of the following: (1)
st = 'info'
for j in range(len(st)):
print(st)
st ='i'
(a) info 4 (b) info info info
(c) info (d) info iii
i
i
i
13. If a program tries to access an array element by specifying index position that is outside the range, it leads
to an ____________. (1)
(a) Error (b) Exclusion
(c) Illegal message (d) Exception
14. When a primary key is combined with a foreign key, it creates— (1)
(a) Many to many relationships between the tables which connect them.
(b) Network model between the tables that connect them.
(c) Parent-child relationship between the tables which connect them.
(d) None of these
15. Which switching technique offers a connectionless service to transfer the packets in a network? (1)
(a) Message Switching (b) Packet Switching
(c) Circuit Switching (d) All of these
16. Which function is used to write the text at the end of the text file? (1)
(a) write() (b) append()
(c) writelines() (d) dump()
Q. 17 and 18 are ASSERTION AND REASONING 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.
17. Assertion (A): Tuples in Python are immutable, meaning their elements cannot be modified after the tuple
is created.
Reasoning (R): Immutability in tuples ensures data integrity and provides certain performance benefits
compared to mutable data structures like lists. (1)
18. Assertion (A): Functions in Python facilitate code reusability and modular programming.
Reasoning (R): By encapsulating a set of instructions within a function, we can call the function multiple
times with different inputs, promoting efficient and organized code development. (1)
SECTION B
19. (i) Expand the following terms: (1)
ARPANET, VOIP
(ii) Differentiate between Active Hub and Passive Hub. (1)
OR

Practice Paper–2 3
(i) What is modem? (1)
(ii) What is the difference between circuit switching and packet switching? (1)
20. The code given below accepts a number as an argument and checks whether the given number is
palindrome or not. Observe the following code carefully and rewrite it after removing all the syntax and
logical errors. Also, underline all the corrections made. (2)
Def is_prime(number):
if no <= 1:
return False
for i in range(2, int(number**0.5) + 1):
if number % i = 0:
return False
return true
num = int(input("Enter a number: "))
if is_prime(num):
print(num, "is a prime number.")
else:
print(num, "is not a prime number.")
21. Write a Python function named find_Average(scores) that takes a list of scores as an argument.
The function should calculate and return the average of the scores. Additionally, display the scores that
are above the calculated average. For example, consider the following list of scores: (2)
scores = [85, 92, 78, 95, 88]
The function should return the average (rounded to two decimal places) and print the scores that are above
the calculated average. (Note: Do not use in-built functions)
OR
Write a Python function named remove_Duplicates(word)that takes a string as an argument. The
function should return a new string with duplicate characters removed, preserving the order of the
remaining characters.
For example, consider the following word: (2)
word = "programming"
The function should return a new string with duplicates removed:
"progamin"
22. Predict the output with respect to the list: L = [40,20,30,10,50] (2)
(a) L.append(70)
print(L)
(b) L.sort()
print(L)
23. Write a Python statement to accomplish the following tasks using built-in functions/methods: (2)
You have a list named Numbers and want to insert an element 150 at the second position and then print
the list in reverse order.
24. Mr. Nagpal has created a table named “Book” with columns Title, Author and Price. Realizing that he needs
to keep track of the publication year, he decides to add a new column named Publication_Year of type
integer to the table. Write an SQL command to add this new column to the “Book” table. After adding the
column, provide SQL command to update Publication Year for book with the title “The Great Novel” to
the year 2022.
Write SQL commands for adding the new column and updating the publication year. (2)
OR

4 Practice Paper–2
Zara is managing a database named “MUSIC” and has created a table called “Songs” with columns Song_ID,
Song_Title, Artist and Genre. She decides to make some changes to the table. Zara wants to delete the
attribute Genre from the table and add a new attribute called Album of data type string. The new attribute
Album should not allow NULL values. Write SQL commands to perform both tasks — delete the Genre
attribute and add the Album attribute with the specified constraints. Help her write the SQL commands
for removing the existing attribute and adding the new attribute.
25. Predict the output of the following code: (2)
s = "easy2code"
n = len(s)
m = ""
for i in range(0,n):
if(s[i]>='a' and s[i]<='m'):
m = m+s[i].upper()
elif(s[i]>='n' and s[i]<='z'):
m = m+s[i-1]
elif(s[i].isupper()):
m = m+s[i].lower()
else:
m = m+'&'
print(m)
SECTION C
26. Predict the output of the Python code given below: (3)
Data = ["I",120,"J",110,"K",130]
No_of_Times = 0
Alpha = ""
Sum = 0
for X in range(1,6,2):
No_of_Times = No_of_Times + X
Alpha = Alpha + Data[X-1]+"@"
Sum = Sum + Data[X]
print(No_of_Times,Sum,Alpha)
27. Consider the table LAB given below and write the output of the SQL queries that follow. (3)
LabNo ItemName Cost DateOfPurchase Warranty Quantity Functional
L1001 Monitor 35000 2023-01-09 2 9 7
L2002 Printer 15000 2022-10-19 4 3 2
L3003 Scanner 18000 2022-08-21 3 1 1
L4004 Router 2000 2023-05-14 1 5 3
L5005 Modem 2000 2021-11-04 2 8 6
L6006 CPU NULL 2021-02-10 1 2 2
(i) Select count(distinct cost) from LAB where quantity >=2;
(ii) Select LabNo, ItemName, Cost from LAB where DateOfPurchase > "2021-01-10"
and ItemName like "%r";

Practice Paper–2 5
(iii) Select ItemName, Cost, Quantity from Lab where Quantity>5 and cost between
15000 and 35000;
28. Write a function display_oddLines() in Python to read a text file friends.txt and to display odd
number lines from the text file. (3)
OR
Write a function display_ulcase() in Python to read a text file document.txt and to count the total
number of upper case and lower case letters from the text file. (3)
29. Consider the table Planner given below:
Table: Planner
Planner_ID P_Name P_Category Charges Destination
P10032 Surbhi Dwivedi Business Activity 150000 Jaipur
P10033 Mayank Atri Corporate Trips 200000 Pune
P10034 Mandvi Vaidya Alumni Meet 50000 Delhi
P10035 Sonal Jain Business Conference 75000 Gurugram
P10036 Vedant Malik Convocation Event 55000 Delhi
P10037 Shreya Suri IT Event 45000 Gurugram
Based on the given table, write SQL queries for the following:
(i) Delete the record of Planner whose charges is greater than 100000.
(ii) Add a new column Contact_No to the above given table.
(iii) Increase the charges by 10% whose Destination is Delhi.
30. Write a program to implement a stack for the movie – details (movie no, movie name). That is how each
item node of the Stack contains two types of information – movie no. and its name. Implement Push and
display operations. (3)
SECTION D
31. Consider the tables SCHOOL and ADMIN given below: (4)
Table: SCHOOL
CODE TEACHER_NAME SUBJECT DATEOFJOINING NO_OF_LECTURES EXPERIENCE
1001 Manju Kumari Hindi 2000-04-19 24 15
1009 Avneet Kaur Physics 2001-09-8 30 10
1023 Vikas Sharma Computer 2017-10-18 19 11
1098 Richa Arora English 2005-02-01 26 2
1123 Suraj Sabharwal Accounts 2021-08-10 25 5
1780 Sunil Kumar English 2001-07-25 32 3
Table: ADMIN
CODE GENDER DESIGNATION
1001 Female Vice Principal
1009 Female Co-ordinator
1023 Male Co-ordinator
1098 Female HOD
1123 Male Senior Teacher
1780 Male HOD

6 Practice Paper–2
Write SQL queries for the following:
(i) Display teacher name and corresponding designation from the tables SCHOOL and ADMIN.
(ii) Display the maximum and minimum experience of teachers whose name contain letter ‘a’.
(iii) Display the sum of no. of lectures subject wise from table SCHOOL.
(iv) Display the teachers’ name, subject and code in the descending order of their date of joining.
32. Mayra is a data analyst at a research institute, and she’s working on a project to analyze temperature
data. To streamline the data management process, she decides to create a CSV file named
"TemperatureData.csv" to store information about daily temperatures. The structure of
"TemperatureData.csv" is defined as follows:
(4)
[Date, Location, Max_Temperature, Min_Temperature]
Where:
Date is the date of the temperature record
Location is the place where the temperature is recorded
Max_Temperature is the maximum temperature for the day
Min_Temperature is the minimum temperature for the day
For efficiently maintaining data, Mayra wants to write the following user defined function:
Record_Temperature(): This function should prompt the user to input information about the daily
temperature (Date, Location, Max_Temperature and Min_Temperature).
The entered record should be added to the “TemperatureData.csv” file, and column headings should be
added if the file is empty.
HighTemperature_Days(): This function should read the “TemperatureData.csv” file and determine
the number of days where the maximum temperature exceeded a certain threshold (let’s say 30 degrees
Celsius). The count of days with high temperatures should be returned.
SECTION E
33. Info Corporation has set up its new centre at Gurugram, Haryana for its office and web-based activities. It
has 4 blocks of buildings. (5)

Infor Corporation
Block A Block D

Block B Block C

Distance between the various blocks is as follows:
A to B 40 m
B to C 120 m
C to D 100 m
A to D 170 m
B to D 150 m
A to C 70 m
Number of computers in each block
Block A 25
Block B 50
Block C 125
Block D 10

Practice Paper–2 7
(a) Suggest and draw the cable layout to efficiently connect various blocks of the building within the
Gurugram centre for connecting the devices.
(b) Suggest the placement of the following devices with justification—
(i) Server
(ii) Repeater
(c) Mention the type of network (PAN/LAN/MAN/WAN) that will be formed if the Gurugram office is
connected to its head office in South Delhi?
(d) Which fast and very effective wireless transmission medium should preferably be used to connect the
head office in South Delhi with the centre in Gurugram?
(e) Suggest the protocol that will be needed for video conferencing solution.
34. (i) Differentiate between readline() and readlines() method of a text file in Python. (2)
(ii) Consider a binary file "MEMBER.DAT" containing records of the following structure: (3)
[EID, Ename, designation, salary]
Write a function, add_data() to add more records of employees in existing file MEMBER.dat. And also
write a function Show_data() in Python that would read detail of employee from file "MEMBER.dat"
and display the details of those employees whose designation is “Salesman”.
OR
(i) Define the term pickling. (2)
(ii) Consider a binary file named"Exam.dat" with some records of the following structure: (3)
[ExamId, Subject, MaxMarks, ScoredMarks]
Write a function in Python named AvgMarks(Sub) that will accept a subject as an argument and read
the contents of Exam.dat. The function will calculate and display the average of the ScoredMarks of the
passed subject.
35. (i) What is Referential Integrity? (2)
(ii) The code given below inserts the following record in the table Student: (3)
Name – string
Gender – string
DOB – date
Stream – string
Marks – integer
Note the following to establish connectivity between Python and MySQL:
• Username – root
• Password - 123
• Host – localhost
The table exists in a MySQL database named School.
The details (Name, Gender, DOB, Stream and Marks) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1– to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Student
Statement 3 – to add the record permanently in the database

8 Practice Paper–2
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",passwd="123",
database="school")
mycursor=_____________ #Statement1
Name = input("Enter name:")
Gender = input("Enter Gender:")
DOB = input("Enter Date of Birth:")
Stream = input("Enter Stream:")
Marks = int(input("Enter marks:"))
querry = "insert into student values ('{0}','{1}','{2}','{3}',{4})".
format(Name,Gender,DOB,Stream,Marks)
_________________________ #Statement2
_________________________ #Statement3
print("Data Added successfully")
OR
(i) Differentiate between Alter Table and Update command in SQL. Also, write the syntax along with
example of each. (2)
(ii) Karan has set up a table named "Emp" in a MySQL database named "MNC": (3)
emp_id (Employee ID) - integer
emp_name (Employee Name) - string
emp_position (Employee Position) - string
emp_salary (Employee Salary) - float
Karan wants to establish connectivity between Python and MySQL with the following database
credentials:
Username: 'admin'
Password: 'pass121'
Host: 'localhost'
Karan is now interested in retrieving records of employees whose salary is greater than 60000. Help
Karan write a Python program to accomplish this task.

Practice Paper–2 9

You might also like