0% found this document useful (0 votes)
59 views9 pages

CS XII - PP-2

Uploaded by

rahulkrana6899
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)
59 views9 pages

CS XII - PP-2

Uploaded by

rahulkrana6899
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/ 9

PRACTICE PAPER 2

CLASS XII
COMPUTER SCIENCE (083)

Time Allowed: 3 hrs Maximum Marks: 70

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.

Section A
1. State whether the following statement is True or False: (1)
If no argument is passed, float() returns 0 as output.
2. Identify the output of the following code snippet. (1)

Str2 = " computerProgramming ".strip().capitalize().replace("o", "0").
replace("e", "3")
(a) Computerprogramming
(b) C0mput3rpr0gramming
(c) C0mputErPr0gramming
(d) C0mput3rpr0gramming
3. Which of the following expressions evaluates to False? (1)
(a) bool([])
(b) 5 != 5
(c) len("abc") == 3
(d) True and (False or True)
4. What will be the output of the given expression? (1)

nums = (5, 10, 15); nums * 2
(a) (5, 10, 15, 5, 10, 15) (b) Error
(c) (5, 10, 15, 2) (d) (10, 20, 30)
5. Identify the output of the following code. (1)

s = "Innovation"
print(s[-2:-9:-3])
(a) vno (b) oan
(c) vnt (d) nao

Practice Paper A.1


6. What will be the output of the given code? (1)
dictt = {'a': 1, 'b': 2, 'c': 3}
keys = list(dictt.keys())
print(dictt.get(keys[0]))
(a) 1 (b) a
(c) None (d) Error
7. Predict the output of the following code. (1)
try:
print("Trying to open file")
file = open("non_existent_file.txt")
except FileNotFoundError as e:
print("File not found error")
finally:
print("Execution finished")
(a) Trying to open file
File not found error
(b) Trying to open file
File not found error
Execution finished
(c) Execution finished
(d) Error
8. What is the function of index() method in a list? (1)
(a) To find the total number of elements in the list
(b) To find the position of the first occurrence of a specified element
(c) To check if an element is present in the list
(d) To remove an element from a given position
9. Which of the following best describes the relationship between primary and foreign keys in a database? (1)
(a) A primary key in one table must always correspond to a primary key in another table.
(b) A foreign key in one table references a primary key in the same table only.
(c) A foreign key in one table establishes a link to a primary key in another table to enforce referential
integrity.
(d) A primary key is required to reference multiple foreign keys in different tables simultaneously.
10. What will be the missing statement to check if the file cursor is at the end of the file? (1)
fileobj = open("sample.txt", "r")
while True:
line = fileobj.readline()
if not line:
____________________
break
fileobj.close()
(a) fileobj.seek(0) (b) fileobj.close()
(c) print("End of file reached") (d) fileobj.tell()

A.2 Computer Science–XII


11. State whether the following statement is True or False: (1)
The else block will not execute if try block contains a return statement.
12. What will be the output of the following code? (1)
count = 0
def outer():
count = 5
def inner():
global count
count += 2
print("Inner count:", count)
inner()
print("Outer count:", count)
outer()
print("Global count:", count)
(a) Inner count: 2

Outer count: 5

Global count: 2
(b) Inner count: 7

Outer count: 5

Global count: 7
(c) Inner count: 7

Outer count: 7

Global count: 5
(d) Inner count: 2

Outer count: 2

Global count: 2
13. Which SQL command would you use to change the name of an existing table from Students to Learners? (1)
14. What will be the output of the given query? (1)

SELECT * FROM sales WHERE customer_ID = 102 OR purchase_date > '2023-06-01';
(a) Details of sales made to customer ID 102 and all purchases after June 1, 2023
(b) Details of all sales made to customers other than 102 before June 1, 2023
(c) Details of all sales made to customer ID 102 or purchases after June 1, 2023
(d) Details of purchases made after June 1, 2023 only if the customer ID is 102
15. Which data type would you choose to store a 10-digit phone number including the country code? (1)
(a) CHAR(10) (b) VARCHAR(15)
(c) INT(10) (d) DATE
16. Which of the following is true about DISTINCT keyword in SQL? (1)
(a) It allows duplicates in query results.
(b) It removes duplicate rows from the result set.
(c) It filters out NULL values from the result set.
(d) It is used to sort data in ascending order.

Practice Paper A.3


17. Which protocol is used to retrieve email messages from a mail server? (1)
(a) FTP (b) POP3
(c) HTTP (d) IMAP
18. Identify the device that is used to amplify and regenerate signals to extend the range of a communication
signal. (1)
(a) Router (b) Repeater
(c) Switch (d) Hub
19. Which switching technique is most commonly used in the internet to handle data traffic? (1)
Q20 and Q21 are Assertion (A) and Reasoning (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 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.
20.
Assertion (A): Default arguments in Python functions are evaluated only once when the function is defined.
Reasoning (R): This is because default arguments are mutable and retain any changes made during function

calls. (1)
21. Assertion (A): COUNT() function in SQL can be used with DISTINCT keyword to count unique values in a
column.
Reasoning (R): COUNT() function only counts the number of rows and does not consider distinct values by

default. (1)

Section B
22. What is the difference between a list and a tuple in Python? Write the syntax to define a list and a tuple. (2)
23. Write two ways to create a duplicate list. (2)
24. Answer the following using built-in functions only.
If Dict1 = {'aa': 1, 'bb': 2, 'cc': 3, 'dd': 4, ...} and Dict2 = {'x1':
10, 'y1': 20, 'z1': 30, ...}, then (2)
(I) (A) Write a statement to get the value associated with the key ‘bb’ in Dict1.
OR
(B) Write a statement to add a new key-value pair 'dd':5 to the dictionary Dict1.
(II) (A) Write a statement to update Dict1 with all key-value pairs from Dict2.
OR
(B) Write a statement to remove the key ‘aa’ from Dict1.
25. From the given options, identify the correct output(s) of the following code. Write the minimum and
maximum possible values of the variable c. (2)
import random
text = "CodingSkills"
c = random.randint(3, 6)
for i in range(len(text)-1, c-1, -2):
print(text[i], end='|')
(a) c| (b) s|l|
(c) s|l|k| (d) s|l|k|c|

A.4 Computer Science–XII


26. The code provided below is intended to reverse the characters in a given string, with each character separated
by a hyphen (-). However, there are syntax and logical errors in the code. Rewrite it after removing all the
errors and underline all the corrections made. (2)
def reverse_str(string)
rev_str = ""
for in range(len(string)-1, -1, -1)
rev_str += string[j] + '-'
return rev_str[0:-1]
result = reverse_str("Source Code")
print("Reversed string with hyphens:" result)

27. (I) (A) Which constraint should be applied to a table column to ensure that a specified default value is
automatically assigned if no value is provided during insertion? (2)
OR
(B) Which constraint should be used on a table column to ensure that only values from a specific range
are allowed in the column?
(II) (A) Write an SQL command to remove UNIQUE constraint from the column Username in a table named
USERS.
OR
(B) Write an SQL command to add NOT NULL constraint to an existing column Email in the table USERS.
28. (A) List any four objectives of FTP. (2)
OR
(B) List one advantage and one disadvantage of Infrared Transmission.

Section C
29. (A) Write a Python function that reads a text file "DocList.txt" and displays the total number of sentences
in the file (consider each line as a sentence). (3)
OR
(B) Write a Python function that reads ‘Novel.txt’ and displays the last 5 words from the file.
30. You have a Stack named TaskStack that contains records of tasks. Each task record is represented as a list
containing task_id, task_name and priority. (3)
Write the following user-defined functions in Python to perform the specified operations on the Stack
TaskStack:
(I) push_task(TaskStack, new_task): This function takes the Stack ‘TaskStack’ and a new task record
‘new_task’ as arguments and pushes the new task record onto the Stack.
(II) pop_task(TaskStack): This function pops the topmost task record from the Stack and returns it. If
the stack is already empty, the function should display ‘Underflow’.
(III) peep(TaskStack): This function displays the topmost element of the Stack without deleting it. If the
Stack is empty, the function should display ‘None’.
OR

Practice Paper A.5


Write the definition of the user-defined function ‘Push_vowels(word)’ that accepts a single word and pushes
each vowel in the word onto a Stack named VowelStack.
Write another function Pop_vowel() to pop the topmost vowel from VowelStack and return it. If the Stack is
empty, it should display ‘No vowels in stack’.
Write function Display_vowels() to display all vowels in VowelStack without removing them. If the Stack is
empty, the function should display ‘None’.
31. Predict the output of the following code. (3)
data_rec = {'R1': (10, 22, 38), 'R2': (94, 15, 56)}
for key, value in data_rec.items():
if 22 in value:
data_rec[key] = value + (40,)
print("Modified dictionary:", data_rec)
OR
Predict the output of the following code.
values = [2, 4, 6, 8]
for x in range(len(values)):
values.insert(x , values.pop())
print("Reordered list is:", values)

Section D
32. Consider the table MOVIES and answer the following questions. (4)

Movie_ID Title Genre Director_Name Box_Office Year_Released


1 Inception Sci-Fi Christopher Nolan 836,800,000 2010
2 The Dark Knight Action Christopher Nolan 1,005,000,000 2008
3 Avatar Sci-Fi James Cameron 2,847,000,000 2009
Note: The table contains more records than shown here.
(A) Write the following queries:
(I) To display the total Box_Office earnings for each Genre, excluding Genres with total earnings less than
10 million.
(II) To display MOVIES table sorted by Box_Office in descending order.
(III) To display the distinct director names from MOVIES table.
(IV) To display the sum of Box_Office for all movies where Year_Released is NULL.
OR
(B) Write the output of the following:
(I) SELECT Director_Name, sum(Box_Office) as total_earnings FROM MOVIES
GROUP BY Director_Name;
(II) SELECT * FROM MOVIES WHERE Genre LIKE '%on%';
(III) SELECT Movie_ID, Title, Genre, Box_Office FROM MOVIES WHERE Box_Office
BETWEEN 5000000 AND 20000000;
(IV) SELECT MAX(Box_Office) FROM MOVIES;

A.6 Computer Science–XII


33. A CSV file, ‘AnimalSurvey.csv’, contains the data of a survey. Each record of the file contains the following
data:
• Species (4)
• Habitat
• Population Count
• Protected Status (Yes/No)
For example, a sample record of the file may be:
[‘Panda’, ‘Forest’, 1864, ‘Yes’]
Write the following Python functions to perform the specified operations on this file:
(I) Read all the data from the file in the form of a list and display all those records for which the population
is more than 2000.
(II) Count the number of species with Protected Status marked as ‘Yes’.
34. Samarth is working as a Database Administrator in an ecommerce company and using EcommerceDB to
manage its inventory and customer orders. There are two tables: PRODUCTS and ORDERS. Help him extract
the following information by writing the desired SQL queries as mentioned below. (4)
Table: PRODUCTS

Product_ID Product_Name Category Price Stock

P7001 Wireless Mouse Electronics 1500 100


P7002 Gaming Keyboard Electronics 3500 50
P7003 Office Chair Furniture 7800 30
P7004 Laptop Bag Accessories 2000 150

Table: ORDERS

Order_ID Product_ID Customer_Name Order_Date Quantity Total_Amount


801 P7001 Samaira 2024-10-20 2 3000
802 P7002 Diviyansh 2024-11-02 1 3500
803 P7003 Mehak 2024-09-21 1 7800
804 P7004 Nimish 2024-08-09 3 6000
(I) To display the details of products in ‘Electronics’ category that are priced above 30.
(II) To display the total sales for each product (Quantity * Price).
(III) To reduce the stock of all products by 10.
(IV) (A) To display the names of customers who purchased more than one product of the same type.
OR
(B) To display the Cartesian Product of PRODUCTS and ORDERS tables.
35. SHOPDB database has a table, CUSTOMERS, with the following structure: (4)

Field Type
customerID int(11)
CustomerName varchar(50)
City varchar(30)
totalPurchases float
membership varchar(10)

Practice Paper A.7


Write the following Python function to perform the specified operation:
Add_Update_Display(): to input details of a new customer and store it in CUSTOMERS table. If the
totalPurchases of the new customer is greater than 5000, update the membership field of that customer to
‘Premium’. The function should then retrieve and display all the records from CUSTOMERS table where the
City is ‘New York’ and the membership is ‘Premium’.
Assume the following for Python-Database connectivity:
Host: localhost

User: admin

Password: shop2024

Section E
36. An insurance company needs to store details of its policyholders with the following fields: (5)
• Policy_ID – integer
• Policyholder_Name – string
• Policy_Type – string
• Premium – float
Write Python functions for the following:
1. To input policyholder details and append them to a binary file.
2. To change Policy_Type to ‘Premium’ for all policyholders whose premium is above 5000.
3. To read the binary file and display the details of policyholders whose Policy_Type is ‘Standard’.
37. A logistics company, FastRoute, is establishing a new branch in Hyderabad. The branch has four operational
zones: SHIPPING, WAREHOUSE, OFFICE and IT_SUPPORT while the HEAD OFFICE is in Bengaluru.
Building-to-building distance in the Hyderabad campus is as follows: (5)

HYDERABAD BENGALURU

SHIPPING WAREHOUSE

OFFICE IT SUPPORT

Building-to-building distance:

From To Distance
SHIPPING WAREHOUSE 60 m
SHIPPING OFFICE 80 m
SHIPPING IT_SUPPORT 50 m
WAREHOUSE OFFICE 70 m
WAREHOUSE IT_SUPPORT 40 m
OFFICE IT_SUPPORT 30 m
Distance between Bengaluru head office and Hyderabad campus: 500 km

A.8 Computer Science–XII


Number of computers in each zone is as follows:

SHIPPING 15
WAREHOUSE 20
OFFICE 30
IT_SUPPORT 25
BENGALURU HEAD OFFICE 10
(I) Where would you place the server in the Hyderabad campus and why?
(II) Which networking hardware is ideal for connecting computers within each zone?
(III) Draw the cable layout for optimal connectivity between buildings in Hyderabad and recommend the
best type of cable for stable data flow.
(IV) Is a repeater necessary in the given cable layout? Provide a reason for your answer.
(V) (A) Which of the following is the best option for fast data sharing between the Hyderabad branch and
Bengaluru head office?
(a) Videoconferencing
(b) File Transfer Protocol (FTP)
(c) Telephony
(d) Email
OR
(B) Which type of network (PAN, LAN, MAN or WAN) would be implemented within the Hyderabad
campus?

Practice Paper A.9

You might also like