0% found this document useful (0 votes)
1K views270 pages

Class XII Computer Science Sample Paper

Uploaded by

luciferxt09
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)
1K views270 pages

Class XII Computer Science Sample Paper

Uploaded by

luciferxt09
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

SAMPLE QUESTION PAPER (THEORY)

CLASS: XII SESSION: 2024-25


COMPUTER SCIENCE (083)

Time allowed: 3 Hours 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.

Q No. Section-A (21 x 1 = 21 Marks) Marks

1. State True or False:


(1)
The Python interpreter handles logical errors during code execution.

2. Identify the output of the following code snippet:


text = "PYTHONPROGRAM"
text=[Link]('PY','#')
print(text)
(1)
(A) #THONPROGRAM
(B) ##THON#ROGRAM
(C) #THON#ROGRAM
(D) #YTHON#ROGRAM

3. Which of the following expressions evaluates to False?


(A) not(True) and False
(B) True or False (1)
(C) not(False and True)
(D) True and not(False)

4. What is the output of the expression?


country='International'
print([Link]("n"))
(A) ('I', 'ter', 'atio', 'al') (1)
(B) ['I', 'ter', 'atio', 'al']
(C) ['I', 'n', 'ter', 'n', 'atio', 'n', 'al']
(D) Error

Page: 1/11
5. What will be the output of the following code snippet?
message= "World Peace" (1)
print(message[-2::-2])

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


tuple1 = (1, 2, 3)
tuple2 = tuple1
tuple1 += (4,)
print(tuple1 == tuple2) (1)
(A) True
(B) False
(C) tuple1
(D) Error

7. If my_dict is a dictionary as defined below, then which of the following


statements will raise an exception?
my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
(A) my_dict.get('orange') (1)
(B) print(my_dict['apple', 'banana'])
(C) my_dict['apple']=20
(D) print(str(my_dict))

8. What does the [Link](x) method do in Python?


(A) Removes the element at index x from the list
(B) Removes the first occurrence of value x from the list (1)
(C) Removes all occurrences of value x from the list
(D) Removes the last occurrence of value x from the list

9. If a table which has one Primary key and two alternate keys. How many
Candidate keys will this table have?
(A) 1
(1)
(B) 2
(C) 3
(D) 4

10. Write the missing statement to complete the following code:


file = open("[Link]", "r")
data = [Link](100)
____________________ #Move the file pointer to the (1)
beginning of the file
next_data = [Link](50)
[Link]()

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


The finally block in Python is executed only if no exception occurs
(1)
in the try block.

Page: 2/11
12. What will be the output of the following code?
c = 10
def add():
global c
c = c + 2
print(c,end='#')
add() (1)
c=15
print(c,end='%')
(A) 12%15#
(B) 15#12%
(C) 12#15%
(D) 12%15#

13. Which SQL command can change the degree of an existing relation? (1)

14. What will be the output of the query?


SELECT * FROM products WHERE product_name LIKE
'App%';
(A) Details of all products whose names start with 'App' (1)
(B) Details of all products whose names end with 'App'
(C) Names of all products whose names start with 'App'
(D) Names of all products whose names end with 'App'

15. In which datatype the value stored is padded with spaces to fit the specified
length.
(A) DATE
(1)
(B) VARCHAR
(C) FLOAT
(D) CHAR

16. Which aggregate function can be used to find the cardinality of a table?
(A) sum()
(B) count() (1)
(C) avg()
(D) max()

17. Which protocol is used to transfer files over the Internet?


(A) HTTP
(B) FTP
(C) PPP
(D) HTTPS (1)

Page: 3/11
18. Which network device is used to connect two networks that use different
protocols?
(A) Modem
(1)
(B) Gateway
(C) Switch
(D) Repeater

19. Which switching technique breaks data into smaller packets for
transmission, allowing multiple packets to share the same network (1)
resources.

Q20 and Q21 are Assertion(A) and Reason(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 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

20. Assertion (A): Positional arguments in Python functions must be passed in


the exact order in which they are defined in the function
signature. (1)
Reasoning (R): This is because Python functions automatically assign
default values to positional arguments.

21. Assertion (A): A SELECT command in SQL can have both WHERE and
HAVING clauses.
Reasoning (R): WHERE and HAVING clauses are used to check (1)
conditions, therefore, these can be used interchangeably.

Q No Section-B ( 7 x 2=14 Marks) Marks

22. How is a mutable object different from an immutable object in Python?


Identify one mutable object and one immutable object from the following: (2)
(1,2), [1,2], {1:1,2:2}, ‘123’

23. Give two examples of each of the following:


(2)
(I) Arithmetic operators (II) Relational operators

24. If L1=[1,2,3,2,1,2,4,2, . . . ], and L2=[10,20,30, . . .], then


(Answer using builtin functions only)
(I)
A) Write a statement to count the occurrences of 4 in L1. (2)
OR
B) Write a statement to sort the elements of list L1 in ascending
order.

Page: 4/11
(II)
A) Write a statement to insert all the elements of L2 at the end of L1.
OR
B) Write a statement to reverse the elements of list L2.

25. Identify the correct output(s) of the following code. Also write the minimum
and the maximum possible values of the variable b.
import random
a="Wisdom"
b=[Link](1,6)
(2)
for i in range(0,b,2):
print(a[i],end='#')

(A) W# (B) W#i#

(C) W#s# (D) W#i#s#

26. The code provided below is intended to swap the first and last elements of
a given tuple. However, there are syntax and logical errors in the code.
Rewrite it after removing all errors. Underline all the corrections made.

def swap_first_last(tup)
if len(tup) < 2:
return tup (2)
new_tup = (tup[-1],) + tup[1:-1] + (tup[0])
return new_tup

result = swap_first_last((1, 2, 3, 4))


print("Swapped tuple: " result)

27. (I)
A) What constraint should be applied on a table column so that
duplicate values are not allowed in that column, but NULL is
allowed.
OR
B) What constraint should be applied on a table column so that (2)
NULL is not allowed in that column, but duplicate values are
allowed.

Page: 5/11
(II)
A) Write an SQL command to remove the Primary Key constraint
from a table, named MOBILE. M_ID is the primary key of the
table.
OR
B) Write an SQL command to make the column M_ID the Primary
Key of an already existing table, named MOBILE.

28. A) List one advantage and one disadvantage of star topology.


OR (2)
B) Expand the term SMTP. What is the use of SMTP?

Q No. Section-C ( 3 x 3 = 9 Marks) Marks

29. A) Write a Python function that displays all the words containing @cmail
from a text file "[Link]".
OR (3)
B) Write a Python function that finds and displays all the words longer than
5 characters from a text file "[Link]".

30. A) You have a stack named BooksStack that contains records of books.
Each book record is represented as a list containing book_title,
author_name, and publication_year.
Write the following user-defined functions in Python to perform the
specified operations on the stack BooksStack:
(I) push_book(BooksStack, new_book): This function takes the stack
BooksStack and a new book record new_book as arguments and
pushes the new book record onto the stack.
(II) pop_book(BooksStack): This function pops the topmost book record
from the stack and returns it. If the stack is already empty, the
function should display "Underflow".
(III) peep(BookStack): This function displays the topmost element of (3)
the stack without deleting it. If the stack is empty, the function
should display 'None'.
OR
(B) Write the definition of a user-defined function `push_even(N)` which
accepts a list of integers in a parameter `N` and pushes all those integers
which are even from the list `N` into a Stack named `EvenNumbers`.
Write function pop_even() to pop the topmost number from the stack and
returns it. If the stack is already empty, the function should display "Empty".
Write function Disp_even() to display all element of the stack without
deleting them. If the stack is empty, the function should display 'None'.

Page: 6/11
For example:
If the integers input into the list `VALUES` are:
[10, 5, 8, 3, 12]

Then the stack `EvenNumbers` should store:


[10, 8, 12]

31. Predict the output of the following code:


d = {"apple": 15, "banana": 7, "cherry": 9}
str1 = ""
for key in d:
str1 = str1 + str(d[key]) + "@" + “\n”
str2 = str1[:-1]
print(str2)
(3)
OR

Predict the output of the following code:


line=[4,9,12,6,20]
for I in line:
for j in range(1,I%5):
print(j,’#’,end=””)
print()

Q No. Section-D ( 4 x 4 = 16 Marks) Marks

32. Consider the table ORDERS as given below

O_Id C_Name Product Quantity Price


1001 Jitendra Laptop 1 12000
1002 Mustafa Smartphone 2 10000
1003 Dhwani Headphone 1 1500
Note: The table contains many more records than shown here.
(4)
A) Write the following queries:

(I) To display the total Quantity for each Product, excluding


Products with total Quantity less than 5.
(II) To display the orders table sorted by total price in descending
order.
(III) To display the distinct customer names from the Orders table.

Page: 7/11
(IV) Display the sum of Price of all the orders for which the quantity
is null.
OR
B) Write the output
(I) Select c_name, sum(quantity) as total_quantity
from orders group by c_name;
(II) Select * from orders where product like
'%phone%';
(III) Select o_id, c_name, product, quantity, price
from orders where price between 1500 and 12000;
(IV) Select max(price) from orders;

33. A csv file "[Link]" contains the data of a survey. Each record of the
file contains the following data:
● Name of a country
● Population of the country
● Sample Size (Number of persons who participated in the survey in
that country)
● Happy (Number of persons who accepted that they were Happy)
(4)
For example, a sample record of the file may be:
[‘Signiland’, 5673000, 5000, 3426]
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 5000000.
(II) Count the number of records in the file.

34. Saman has been entrusted with the management of Law University
Database. He needs to access some information from FACULTY and
COURSES tables for a survey analysis. Help him extract the following
information by writing the desired SQL queries as mentioned below.

Table: FACULTY
F_ID FName LName Hire_Date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000 (4)
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra 11-9-2004 11000
106 Sulekha Srivastava 5-6-2006 10000

Table: COURSES
C_ID F_ID CName Fees
C21 102 Grid Computing 40000
C22 106 System Design 16000

Page: 8/11
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000
(I) To display complete details (from both the tables) of those Faculties
whose salary is less than 12000.
(II) To display the details of courses whose fees is in the range of 20000
to 50000 (both values included).
(III) To increase the fees of all courses by 500 which have "Computer"
in their Course names.
(IV) (A) To display names (FName and LName) of faculty taking System
Design.
OR
(B) To display the Cartesian Product of these two tables.

35. A table, named STATIONERY, in ITEMDB database, has the following


structure:

Field Type
itemNo int(11)
itemName varchar(15)
price float
qty int(11)
(4)
Write the following Python function to perform the specified operation:
AddAndDisplay(): To input details of an item and store it in the table
STATIONERY. The function should then retrieve and display all records
from the STATIONERY table where the Price is greater than 120.

Assume the following for Python-Database connectivity:


Host: localhost, User: root, Password: Pencil

[Link]. SECTION E (2 X 5 = 10 Marks) Marks

36. Surya is a manager working in a recruitment agency. He needs to manage


the records of various candidates. For this, he wants the following
information of each candidate to be stored:
- Candidate_ID – integer
- Candidate_Name – string
- Designation – string
- Experience – float (5)

You, as a programmer of the company, have been assigned to do this job


for Surya.

(I) Write a function to input the data of a candidate and append it in a


binary file.

Page: 9/11
(II) Write a function to update the data of candidates whose experience
is more than 10 years and change their designation to "Senior
Manager".
(III) Write a function to read the data from the binary file and display the
data of all those candidates who are not "Senior Manager".

37. Event Horizon Enterprises is an event planning organization. It is planning


to set up its India campus in Mumbai with its head office in Delhi. The
Mumbai campus will have four blocks/buildings - ADMIN, FOOD, MEDIA,
DECORATORS. You, as a network expert, need to suggest the best
network-related solutions for them to resolve the issues/problems
mentioned in points (I) to (V), keeping in mind the distances between
various blocks/buildings and other given parameters.

Block to Block distances (in Mtrs.)


From To Distance
ADMIN FOOD 42 m (5)
ADMIN MEDIA 96 m
ADMIN DECORATORS 48 m
FOOD MEDIA 58 m
FOOD DECORATORS 46 m
MEDIA DECORATORS 42 m
Distance of Delhi Head Office from Mumbai Campus = 1500 km
Number of computers in each of the blocks/Center is as follows:

ADMIN 30
FOOD 18
MEDIA 25
DECORATORS 20
DELHI HEAD
OFFICE 18

Page: 10/11
(I) Suggest the most appropriate location of the server inside the
MUMBAI campus. Justify your choice.
(II) Which hardware device will you suggest to connect all the
computers within each building?
(III) Draw the cable layout to efficiently connect various buildings
within the MUMBAI campus. Which cable would you suggest for
the most efficient data transfer over the network?
(IV) Is there a requirement of a repeater in the given cable layout?
Why/ Why not?
(V) A) What would be your recommendation for enabling live visual
communication between the Admin Office at the Mumbai campus
and the DELHI Head Office from the following options:
a) Video Conferencing
b) Email
c) Telephony
d) Instant Messaging
OR
B) What type of network (PAN, LAN, MAN, or WAN) will be set up
among the computers connected in the MUMBAI campus?

Page: 11/11
MARKING SCHEME
Class: XII Session: 2024-25
Computer Science (083)

Time allowed: 3 Hours Maximum Marks: 70


Q No. SECTION A (21X1=21) Marks
1. False (1)
(1 mark for correct answer)
2. (A) #THONPROGRAM
(1)
(1 mark for correct answer)
3. (A) not (True) and False
(1)
(1 mark for correct answer)
4. (B) ['I', 'ter', 'atio', 'al']
(1)
(1 mark for correct answer)
5. ce lo
(1)
(1 mark for correct answer)
6. (B) False
(1)
(1 mark for correct answer)
7. (B) print(my_dict['apple', 'banana'])
(1)
(1 mark for correct answer)
8. (B) Removes the first occurrence of value x from the list
(1)
(1 mark for correct answer)
9. (C) 3
(1)
(1 mark for correct answer)
10. [Link](0) ( OR [Link](0,0) )
(1)
(1 mark for correct answer)
11. False
(1)
(1 mark for correct answer)
12. (C) 12#15%
(1)
(1 mark for correct answer)
13. Alter (or Alter Table) (1)
(1 mark for correct answer)

Page: 1/11
14. (A) Details of all products whose names start with 'App'
(1)
(1 mark for correct answer)
15. (D) CHAR
(1)
(1 mark for correct answer)
16. (B) count()
(1)
(1 mark for correct answer)
17. (B) FTP
(1)
(1 mark for correct answer)
18. (B) Gateway
(1)
(1 mark for correct answer)
19. (B) Packet Switching
(1)
(1 mark for correct answer)
20. (C) A is True but R is False.
(1)
(1 mark for correct answer)
21. (C) A is True but R is False.
(1)
(1 mark for correct answer)

Q No. SECTION B (7 X 2 =14) Marks


22. A mutable object can be updated whereas an immutable object cannot be
updated.
Mutable object: [1,2] or {1:1,2:2} (Any one)
(2)
Immutable object: (1,2) or ‘123’ (Any one)
(1 mark for correct difference)
(½ x 2 = 1 Mark for selecting correct objects)
23. (I) Arithmetic operators: +,-

(II) Relational operators: >, >= (2)

(½ x 4 = 2 Marks for each correct operator)


24. (I)
A) [Link](4)
OR
B) [Link]() (2)
(1 mark for correct answer)

Page: 2/11
(II)
A) [Link](L2)
OR
B) [Link]()
(1 mark for correct answer)
25. (A), (C)
(½ x 2 = 1 Mark)
(2)
Minimum and maximum possible values of the variable b: 1,6
(½ x 2 = 1 Mark)
26. def swap_first_last(tup):
if len(tup) < 2:
return tup
new_tup = (tup[-1],) + tup[1:-1] + (tup[0],)
return new_tup
(2)

result = swap_first_last((1, 2, 3, 4))


print("Swapped tuple:", result)

(½ mark each for correcting 4 mistakes)


27. (I)
A) UNIQUE
OR
B) NOT NULL
(1 mark for correct answer)
(2)
(II)
A) ALTER TABLE MOBILE DROP PRIMARY KEY;
OR
B) ALTER TABLE MOBILE ADD PRIMARY KEY (M_ID);
(1 mark for correct answer)
28. A) Advantage: Network extension is easy.

Disadvantage: Failure of switch/hub results in failure of the network.


(1 mark for correct Advantage)
(2)
(1 mark for correct Disadvantage)

OR

Page: 3/11
B) SMTP: Simple Mail Transfer Protocol.

SMTP is used for sending e-mails from client to server.


(1 mark for correct expansion)
(1 mark for correct usage)

Q No. SECTION C (3 X 3 = 9) Marks


29. (A)

def show():
f=open("[Link]",'r')
data=[Link]()
words=[Link]()
for word in words:
if '@cmail' in word:
print(word,end=' ')
[Link]()
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for splitting the text into words)
(1 mark for correctly displaying the desired words) (3)
OR
(B)
def display_long_words():
with open("[Link]", 'r') as file:
data=[Link]()
words=[Link]()
for word in words:
if len(word)>5:
print(word,end=' ')
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
( ½ mark for splitting the text into words)
(1 mark for correctly displaying the desired words)

Page: 4/11
30. (A)
(I)
def push_book(BooksStack, new_book):
[Link](new_book)
(II)
def pop_book(BooksStack):
if not BooksStack:
print("Underflow")
else:
return([Link]())
(III)
def peep(BooksStack):
if not BooksStack:
print("None")
else:
print(BookStack[-1])
(3x1 mark for correct function body; No marks for any function header as it
was a part of the question)
OR
(B)
def push_even(N):
(3)
EvenNumbers = []
for num in N:
if num % 2 == 0:
[Link](num)
return EvenNumbers

VALUES = []

for i in range(5):
[Link](int(input("Enter an integer: ")))

EvenNumbers = push_even(VALUES)

def pop_even():
if not EvenNumbers:
print("Underflow")
else:
print([Link]())

pop_even()

Page: 5/11
def Disp_even():
if not EvenNumbers:
print("None")
else:
print(EvenNumbers[-1])
Disp_even()
(1/2 for identifying even numbers)
(1/2 mark for correctly adding data to stack)
(1/2 mark for correctly poping data on the stack and 1/2 mark for checking
condition)
(1/2 mark for correctly displaying the data with none)
(1/2 mark for function call statements)
31. (A) 15@
7@
9

OR
(3)
(B) 1 #2 #3#
1 #2 #3 #
1#

(1 mark for each correct line of output)


(deduct ½ mark for not printing @/#)

Q No. SECTION D (4 X 4 = 16) Marks


32. (A)
(I) select Product, sum(Quantity) from orders group by product
having sum(Quantity)>=5;
(II) select * from orders order by Price desc;
(III) select distinct C_Name from orders;
(IV) select sum(price) as total_price from orders where Quantity IS
NULL;

(4 x 1 mark for each correct query)


(4)
OR
(B)
(I)

C_Name | Total_Quantity
--------- |---------------
Jitendra |1
Mustafa |2
Dhwani |1

Page: 6/11
(II)

O_Id | C_Name | Product | Quantity | Price


----- |-------- |------------ |---------- |-------
1002 | Mustafa | Smartphone | 2 | 10000
1003 | Dhwani | Headphone | 1 | 1500

(III) O_Id | C_Name | Product | Quantity | Price


----- |---------- |------------ |---------- |-------
1001 | Jitendra | Laptop |1 | 12000
1002 | Mustafa | Smartphone | 2 | 10000
1003 | Dhwani | Headphone | 1 | 1500

(IV)
MAX(Price)
-----------
12000

(4 x 1 mark for each correct output)


33. (I)
def show():
import csv
f=open("[Link]",'r')
records=[Link](f)
next(records, None) #To skip the Header row
for i in records:
if int(i[1])>5000000:
print(i)
[Link]()
(½ mark for opening in the file in right mode)
(½ mark for correctly creating the reader object)
(½ mark for correctly checking the condition)
(½ mark for correctly displaying the records) (4)

(II)
def Count_records():
import csv
f=open("[Link]",'r')
records=[Link](f)
next(records, None) #To skip the Header row
count=0
for i in records:
count+=1
print(count)
[Link]()

Page: 7/11
(½ mark for opening in the file in right mode)
(½ mark for correctly creating the reader object)
(½ mark for correct use of counter)
(½ mark for correctly displaying the counter)
Note (for both parts (I) and (II)):
(i) Ignore import csv as it may be considered the part of the
complete program, and there is no need to import it in individual
functions.
(ii) Ignore next(records, None) as the file may or may not have the
Header Row.
34. (I) Select * from FACULTY natural join COURSES where Salary<12000;
Or
Select * from FACULTY, COURSES where Salary<12000 and
facuty.f_id=courses.f_id;
(II) Select * from courses where fees between 20000 and 50000;
(III) Update courses set fees=fees+500 where CName like
'%Computer%';
(IV)
(A) Select FName, LName from faculty natural join courses where
Came="System Design"; (4)
Or
Select FName, LName from faculty, courses where Came="System
Design" and facuty.f_id=courses.f_id;

OR

(B) Select * from FACULTY, COURSES;

(4x1 mark for each correct query)


35. def AddAndDisplay():
import [Link] as mycon
mydb=[Link](host="localhost",user="root",
passwd="Pencil",database="ITEMDB")
mycur=[Link]()
no=int(input("Enter Item Number: "))
nm=input("Enter Item Name: ")
pr=float(input("Enter price: "))
qty=int(input("Enter qty: "))
query="INSERT INTO stationery VALUES ({},'{}',{},{})" (4)
query=[Link](no,nm,pr,qty)
[Link](query)
[Link]()
[Link]("select * from stationery where price>120")
for rec in mycur:
print(rec)

Page: 8/11
(½ mark for correctly importing the connector object)
(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(½ mark for correct creation of first query)
(½ mark for correctly executing the first query with commit)
(½ mark for correctly executing the second query)
(½ mark for correctly displaying the data)

Q No. SECTION E (2 X 5 = 10) Marks


36. (I) (5)
import pickle

def input_candidates():
candidates = []
n = int(input("Enter the number of candidates you want to add: "))
for i in range(n):
candidate_id = int(input("Enter Candidate ID: "))
candidate_name = input("Enter Candidate Name: ")
designation = input("Enter Designation: ")
experience = float(input("Enter Experience (in years): "))
[Link]([candidate_id, candidate_name, designation,
experience])
return candidates
candidates_list = input_candidates()

def append_candidate_data(candidates):
with open('[Link]', 'ab') as file:
for candidate in candidates:
[Link](candidate, file)
print("Candidate data appended successfully.")

append_candidate_data(candidates_list)

(II)
import pickle

def update_senior_manager():
updated_candidates = []
try:
with open('[Link]', 'rb') as file:
while True:
try:
candidate = [Link](file)
if candidate[3] > 10: # If experience > 10 years
candidate[2] = 'Senior Manager'
updated_candidates.append(candidate)
except EOFError:

Page: 9/11
break # End of file reached
except FileNotFoundError:
print("No candidate data found. Please add candidates first.")
return

with open('[Link]', 'wb') as file:


for candidate in updated_candidates:
[Link](candidate, file)

print("Candidates updated to Senior Manager where applicable.")


update_senior_manager()

(III)

import pickle

def display_non_senior_managers():
try:
with open('[Link]', 'rb') as file:
while True:
try:
candidate = [Link](file)
if candidate[2] != 'Senior Manager': # Check if not Senior
Manager
print(f"Candidate ID: {candidate[0]}")
print(f"Candidate Name: {candidate[1]}")
print(f"Designation: {candidate[2]}")
print(f"Experience: {candidate[3]}")
print("--------------------")
except EOFError:
break # End of file reached
except FileNotFoundError:
print("No candidate data found. Please add candidates first.")

display_non_senior_managers()

(1/2 mark of import pickle)


(1/2 mark for input)
(1/2 mark for opening file in append mode and 1/2 mark for using dump)
(1/2 mark for opening file in read mode and 1/2 mark for using load)
(1 mark for checking the condition and updating the value)
(1 mark for checking the condition and displaying data correctly)
37. (I) ADMIN Block as it has maximum number of computers. (5)
(1 mark for correct answer)

(II) Switch
(1 mark for correct answer)

(III)

Page: 10/11
(or Any other correct layout)
Cable: Coaxial cable
(½ mark for correct layout + ½ mark for correct table type)

(IV) There is no requirement of the Repeat as the optical fibre cable used for
the network can carry the data to much longer distances than within the
campus.
(1 mark for correct answer)

(V) (A) a) Video Conferencing


OR
(B) LAN
(1 mark for correct answer)

Page: 11/11
Class: XII Session: 2023-24
Computer Science (083)
Sample Question Paper (Theory)
Time allowed: 3 Hours Maximum Marks: 70
General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into 4 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 to 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.

Que Question Marks


s No
SECTION A
1 State True or False: 1
“In a Python program, if a break statement is given in a nested loop, it
terminates the execution of all loops in one go.”
2 In a table in MYSQL database, an attribute A of datatype varchar(20) 1
has the value “Keshav”. The attribute B of datatype char(20) has value
“Meenakshi”. How many characters are occupied by attribute A and
attribute B?
a. 20,6 b. 6,20
c. 9,6 d. 6,9

3 What will be the output of the following statement: 1


print(3-2**2**3+99/11)
a. 244 b. 244.0
c. -244.0 d. Error

4 Select the correct output of the code: 1

[1]
Options:
a. PYTHON-IS-Fun
b. PYTHON-is-Fun
c. Python-is-fun
d. PYTHON-Is -Fun
5 In MYSQL database, if a table, Alpha has degree 5 and cardinality 3, and 1
another table, Beta has degree 3 and cardinality 5, what will be the degree
and cardinality of the Cartesian product of Alpha and Beta?
a. 5,3 b. 8,15
c. 3,5 d. 15,8

6 Riya wants to transfer pictures from her mobile phone to her laptop. She 1
uses Bluetooth Technology to connect two devices. Which type of network
will be formed in this case?
a. PAN b. LAN
c. MAN d. WAN

7 Which of the following will delete key-value pair for key = “Red” from a 1
dictionary D1?
a. delete D1("Red")
b. del D1["Red"]
c. del.D1["Red"]
d. [Link]["Red"]
8 Consider the statements given below and then choose the correct output 1
from the given options:
pride="#G20 Presidency"
print(pride[-[Link]-2])

[2]
Options:
a. ndsr
b. ceieP0
c. ceieP
d. yndsr

9 Which of the following statement(s) would give an error during execution of 1


the following code?
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4

Options:
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4

10 What possible outputs(s) will be obtained when the following code is 1


executed?

Options:
a.

[3]
RED*
WHITE*
BLACK*

b.
WHITE*
BLACK*
c.
WHITE* WHITE*
BLACK* BLACK*

d.
YELLOW*
WHITE*WHITE*
BLACK* BLACK* BLACK*

11 Fill in the blank: 1


The modem at the sender’s computer end acts as a ____________.
a. Model
b. Modulator
c. Demodulator
d. Convertor

12 Consider the code given below: 1

[4]
Which of the following statements should be given in the blank for
#Missing Statement, if the output produced is 110?

Options:
a. global a
b. global b=100
c. global b
d. global a=100

13 State whether the following statement is True or False: 1


An exception may be raised even if the program is syntactically correct.
14 Which of the following statements is FALSE about keys in a relational 1
database?
a. Any candidate key is eligible to become a primary key.
b. A primary key uniquely identifies the tuples in a relation.
c. A candidate key that is not a primary key is a foreign key.
d. A foreign key is an attribute whose value is derived from the primary
key of another relation.

15 Fill in the blank: 1


In case of _____________ switching, before a communication starts, a
dedicated path is identified between the sender and the receiver.
16 Which of the following functions changes the position of file pointer and 1
returns its new position?
a. flush()
b. tell()
c. seek()
d. offset()

Q17 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

[5]
(c) A is True but R is False
(d) A is false but R is True
17 Assertion(A): List is an immutable data type 1
Reasoning(R): When an attempt is made to update the value of an
immutable variable, the old variable is destroyed and a new variable is
created by the same name in memory.
18 Assertion(A): Python Standard Library consists of various modules. 1
Reasoning(R): A function in a module is used to simplify the code and
avoids repetition.

SECTION B
19 (i) Expand the following terms: 1+1=
2
POP3 , URL
(ii) Give one difference between XML and HTML.

OR
(i) Define the term bandwidth with respect to networks.
(ii) How is http different from https?

20 The code given below accepts a number as an argument and returns the 2
reverse number. Observe the following code carefully and rewrite it after
removing all syntax and logical errors. Underline all the corrections made.

[6]
21 Write a function countNow(PLACES) in Python, that takes the 2
dictionary, PLACES as an argument and displays the names (in
uppercase)of the places whose names are longer than 5 characters.
For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New
York",5:"Doha"}
The output should be:
LONDON
NEW YORK
OR
Write a function, lenWords(STRING), that takes a string as an argument
and returns a tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun", the
tuple will have (4, 3, 2, 4, 4, 3)
22 Predict the output of the following code: 2

23 Write the Python statement for each of the following tasks using BUILT-IN 1+1=
2
functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop
/ period or not.

[7]
OR
A list named studentAge stores age of students of a class. Write the
Python command to import the required module and (using built-in
function) to display the most common age value from the given list.
24 Ms. Shalini has just created a table named “Employee” containing 2
columns Ename, Department and Salary.
After creating the table, she realized that she has forgotten to add a primary
key column in the table. Help her in writing an SQL command to add a
primary key column EmpId of integer type to the table Employee.
Thereafter, write the command to insert the following record in the table:
EmpId- 999
Ename- Shweta
Department: Production
Salary: 26900

OR

Zack is working in a database named SPORT, in which he has created a


table named “Sports” containing columns SportId, SportName,
no_of_players, and category.
After creating the table, he realized that the attribute, category has to be
deleted from the table and a new attribute TypeSport of data type string
has to be added. This attribute TypeSport cannot be left blank. Help Zack
write the commands to complete both the tasks.

25 Predict the output of the following code: 2

[8]
SECTION C
26 Predict the output of the Python code given below: 3

27 Consider the table CLUB given below and write the output of the SQL 1*3=
3
queries that follow.

CID CNAME AGE GENDER SPORTS PAY DOAPP


5246 AMRITA 35 FEMALE CHESS 900 2006-
03-27

[9]
4687 SHYAM 37 MALE CRICKET 1300 2004-
04-15
1245 MEENA 23 FEMALE VOLLEYBALL 1000 2007-
06-18
1622 AMRIT 28 MALE KARATE 1000 2007-
09-05
1256 AMINA 36 FEMALE CHESS 1100 2003-
08-15
1720 MANJU 33 FEMALE KARATE 1250 2004-
04-10
2321 VIRAT 35 MALE CRICKET 1050 2005-
04-30

(i) SELECT COUNT(DISTINCT SPORTS) FROM CLUB;


(ii) SELECT CNAME, SPORTS FROM CLUB WHERE
DOAPP<"2006-04-30" AND CNAME LIKE "%NA";
(iii) SELECT CNAME, AGE, PAY FROM CLUB WHERE
GENDER = "MALE" AND PAY BETWEEN 1000 AND
1200;
28 Write a function in Python to read a text file, [Link] and displays 3
those lines which begin with the word ‘You’.
OR
Write a function, vowelCount() in Python that counts and displays the
number of vowels in the text file named [Link].
29 Consider the table Personal given below: 1*3=
3
Table: Personal
P_ID Name Desig Salary Allowance

P01 Rohit Manager 89000 4800

[10]
P02 Kashish Clerk NULL 1600
P03 Mahesh Superviser 48000 NULL

P04 Salil Clerk 31000 1900


P05 Ravina Superviser NULL 2100

Based on the given table, write SQL queries for the following:
(i) Increase the salary by 5% of personals whose allowance is known.
(ii) Display Name and Total Salary (sum of Salary and Allowance) of
all personals. The column heading ‘Total Salary’ should also be
displayed.
(iii) Delete the record of personals who have salary greater than 25000
30 A list, NList contains following record as list elements: 3
[City, Country, distance from Delhi]
Each of these records are nested together to form a nested list. Write the
following user defined functions in Python 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.
(ii) Pop_element(): It pops the objects from the stack and displays
them. Also, the function should display “Stack Empty” when there
are no elements in the stack.
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],

[11]
["Gangtok", "India", 1580],
["Columbo", "Sri Lanka", 3405]]
The stack should contain:
['Naypyidaw', 'Myanmar'],
['Dubai', 'UAE'],
['Columbo', 'Sri Lanka']
The output should be:
['Columbo', 'Sri Lanka']
['Dubai', 'UAE']
['Naypyidaw', 'Myanmar']
Stack Empty

SECTION D
31 Consider the tables PRODUCT and BRAND given below: 1*4=
4
Table: PRODUCT
PCode PName UPrice Rating BID
P01 Shampoo 120 6 M03
P02 Toothpaste 54 8 M02
P03 Soap 25 7 M03
P04 Toothpaste 65 4 M04
P05 Soap 38 5 M05
P06 Shampoo 245 6 M05

Table: BRAND
BID BName
M02 Dant Kanti
M03 Medimix
M04 Pepsodent
M05 Dove

[12]
Write SQL queries for the following:
(i) Display product name and brand name from the tables PRODUCT
and BRAND.
(ii) Display the structure of the table PRODUCT.
(iii) Display the average rating of Medimix and Dove brands
(iv) Display the name, price, and rating of products in descending order
of rating.
32 Vedansh is a Python programmer working in a school. For the Annual 4
Sports Event, he has created a csv file named [Link], to store the
results of students in different sports events. The structure of [Link]
is :
[St_Id, St_Name, Game_Name, Result]
Where
St_Id is Student ID (integer)
ST_name is Student Name (string)
Game_Name is name of game in which student is participating(string)
Result is result of the game whose value can be either 'Won', 'Lost'
or 'Tie'
For efficiently maintaining data of the event, Vedansh wants to write the
following user defined functions:
Accept() – to accept a record from the user and add it to the file
[Link]. The column headings should also be added on top of the csv
file.
wonCount() – to count the number of students who have won any event.
As a Python expert, help him complete the task.

SECTION E

[13]
33 Meticulous EduServe is an educational organization. It is planning to setup 1*5=
5
its India campus at Chennai with its head office at Delhi. The Chennai campus
has 4 main buildings – ADMIN, ENGINEERING, BUSINESS and MEDIA

Block to Block distances (in Mtrs.)


From To Distance
ADMIN ENGINEERING 55 m
ADMIN BUSINESS 90 m
ADMIN MEDIA 50 m
ENGINEERING BUSINESS 55 m
ENGINEERING MEDIA 50 m
BUSINESS MEDIA 45 m
DELHI HEAD CHENNAI 2175 km
OFFICE CAMPUS

Number of computers in each of the blocks/Center is as follows:


ADMIN 110
ENGINEERING 75
BUSINESS 40
MEDIA 12
DELHI HEAD 20

a) Suggest and draw the cable layout to efficiently connect various blocks of
buildings within the CHENNAI campus for connecting the digital devices.

[14]
b) Which network device will be used to connect computers in each block to
form a local area network?
c) Which block, in Chennai Campus should be made the server? Justify your
answer.
d) Which fast and very effective wireless transmission medium
should preferably be used to connect the head office at DELHI with the
campus in CHENNAI?
e) Is there a requirement of a repeater in the given cable layout? Why/
Why not?
34 (i) Differentiate between r+ and w+ file modes in Python. 2+3=
5
(ii) Consider a file, [Link], containing records of the following
structure:
[SportName, TeamName, No_Players]
Write a function, copyData(), that reads contents from the file
[Link] and copies the records with Sport name as “Basket Ball”
to the file named [Link]. The function should return the total
number of records copied to the file [Link].
OR
(i) How are text files different from binary files?
(ii) A Binary file, [Link] has the following structure:
{MNO:[MNAME, MTYPE]}
Where
MNO – Movie Number
MNAME – Movie Name
MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype
as parameter and displays all the records from the binary file
[Link], that have the value of Movie Type as mtype.
35 (i) Define the term Domain with respect to RDBMS. Give one example 1+4=
5
to support your answer.
[15]
(ii) Kabir wants to write a program in Python to insert the following record
in the table named Student in MYSQL database, SCHOOL:
 rno(Roll number )- integer
 name(Name) - string
 DOB (Date of birth) – Date
 Fee – float
Note the following to establish connectivity between Python and
MySQL:
 Username - root
 Password - tiger
 Host - localhost
The values of fields rno, name, DOB and fee has to be accepted from
the user. Help Kabir to write the program in Python.

OR
(i) Give one difference between alternate key and candidate key.

(ii) Sartaj has created a table named Student in MYSQL database,


SCHOOL:
 rno(Roll number )- integer
 name(Name) - string
 DOB (Date of birth) – Date
 Fee – float
Note the following to establish connectivity between Python and
MySQL:
 Username - root
 Password - tiger
 Host - localhost

[16]
Sartaj, now wants to display the records of students whose fee is more than
5000. Help Sartaj to write the program in Python.

[17]
Class XII

Computer Science (083)

Marking Scheme

Time Allowed: 3 hours MM: 70

Ques Question and Answers Distribution Total


No of Marks Marks

SECTION A
1 False 1 mark for 1
correct
answer

2 Option b 1 mark for 1


correct
6,20
answer

3 Option c 1 mark for 1


correct
-244.0 answer

4 PYTHON-is-Fun 1 mark for 1


correct
answer

5 Option b 1 mark for 1


correct
8,15
answer

6 Option a 1 mark for 1


correct
PAN
answer

7 Option b 1 mark for 1


correct
del D1["Red"] answer

8 Option b 1 mark for 1


correct
answer

[1]
ceieP0

9 Option d 1 mark for 1


correct
Statement 4 answer

10 Option b 1 mark for 1


correct
WHITE* answer

BLACK*

11 Option b 1 mark for 1


correct
Modulator answer

12 Option c 1 mark for 1


correct
global b answer

13 True 1 mark for 1


correct
answer

14 Option c 1 mark for 1


correct
A candidate key that is not a primary key is a foreign key. answer

15 Circuit 1 mark for 1


correct
answer

16 Option c 1 mark for 1


correct
seek() answer

17 Option d 1 mark for 1


A is false but R is True correct
answer

[2]
18 Option b 1 mark for 1
correct
Both A and R are true but R is not the correct explanation for A answer

SECTION B
19 (i) ½ mark for 1+1=2
each correct
POP3 – Post Office Protocol 3 expansion

URL – Uniform Resource Locator

(ii)

HTML( Hyper text mark Up language)

 We use pre-defined tags


 Static web development language – only focuses on how
data looks
 It use for only displaying data, cannot transport data
 Not case sensistive

XML (Extensible Markup Language) 1 mark for


any one
correct
 we can define our own tags and use them
difference
 Dynamic web development language – as it is used for
No mark to
transporting and storing data be awarded if
 Case sensitive only full form
is given
OR

(i) Bandwidth is the maximum rate of data transfer over 1 mark for
correct
a given transmission medium. / The amount of definition
information that can be transmitted over a network.

[3]
(ii) https (Hyper Text Transfer Protocol Secure) is the 1 mark for
correct
protocol that uses SSL (Secure Socket Layer) to
difference.
encrypt data being transmitted over the Internet.
Therefore, https helps in secure browsing while http
does not.

20 def revNumber(num): ½ mark for 2


rev = 0 each
rem = 0 correction
while num > 0: made
rem =num %10
rev = rev*10 + rem
num = num//10
return rev
print(revNumber(1234))

21 ½ mark for 2
correct
function
header

½ mark for
correct loop

½ mark for
correct if
statement

½ mark for
displaying
OR
the output

½ mark for
correct
function
header

½ mark for
using split()

[4]
½ mark for
adding to
tuple

½ mark for
return
statement

Note: Any other correct logic may be marked

22 4*L ½ mark for 2


each correct
33*4
line of output
21*S
10*6
23 (i) [Link](2,200) 1 mark for 1+1=2
each correct
(ii) [Link]('.') statement

OR
import statistics
1 mark for
print( [Link](studentAge) )
correct
import
statement

1 mark for
correct
command
with mode()
and print()

24 SQL Command to add primary key: 1 mark for 2


correct
ALTER TABLE Employee ADD EmpId INTEGER ALTER TABLE
command
PRIMARY KEY;

[5]
As the primary key is added as the last field, the command for
inserting data will be: 1 mark for
correct
INSERT INTO Employee INSERT
VALUES("Shweta","Production",26900,999); command

Alternative answer:
INSERT INTO
Employee(EmpId,Ename,Department,Salary)
VALUES(999,"Shweta","Production",26900);
OR
To delete the attribute, category:
1 mark for
ALTER TABLE Sports correct
DROP category; ALTER TABLE
command
with DROP
To add the attribute, TypeSport
1 mark for
correct
ALTER TABLE Sports ALTER TABLE
command
ADD TypeSport char(10) NOT NULL; with ADD

25 10.0$20 1 mark for 2


each correct
10.0$2.0###
line of output

SECTION C
26 ND-*34 ½ mark for 3
each correct
character

27

1 mark for 1*3=3


each correct
(i)
output
COUNT(DISTINCT SPORTS)

[6]
4

(ii)
CNAME SPORTS
AMINA CHESS

(iii)
CNAME AGE PAY
AMRIT 28 1000
VIRAT 35 1050

28 1 mark for 3
correctly
opening and
closing files

½ mark for
correctly
reading data

1 mark for
correct loop
and if
statement
OR
½ mark for
displaying
data

1 mark for
correctly
opening and
closing the
files

[7]
½ mark for
correctly
reading data

1 mark for
correct loop
and if
statement

½ mark for
displaying
the output.

Note: Any other correct logic may be marked


29 (i) 1 mark for 1*3=3
each correct
UPDATE Personal
query
SET Salary=Salary + Salary*0.5
WHERE Allowance IS NOT NULL;

(ii)
SELECT Name, Salary + Allowance AS
"Total Salary" FROM Personal;

(iii)
DELETE FROM Personal
WHERE Salary>25000

[8]
30 1 ½ marks for 3
each function

SECTION D
31 (i) 1 mark for 1*4=4
each correct
SELECT PName, BName FROM PRODUCT P,
query
BRAND B WHERE [Link]=[Link];
(ii)
DESC PRODUCT;
(iii)
SELECT BName, AVG(Rating) FROM PRODUCT
P, BRAND B
WHERE [Link]=[Link]
GROUP BY BName
HAVING BName='Medimix' OR
BName='Dove';
(iv)
SELECT PName, UPrice, Rating
FROM PRODUCT
ORDER BY Rating DESC;

[9]
32 ½ mark for 4
accepting
data
correctly

½ mark for
opening and
closing file

½ mark for
writing
headings

½ mark for
writing row

½ mark for
opening and
closing file

½ mark for
reader object

½ mark for
print heading

½ mark for
printing data

SECTION E
33 a) 1 mark for 1*5=5
each correct
Bus Topology
answer
ENGINEERING
Admin

BUSINESS
MEDIA

[10]
b) Switch
c) Admin block, as it has maximum number of computers.
d) Microwave
e) No, a repeater is not required in the given cable layout as the
length of transmission medium between any two blocks does not
exceed 70 m.

34 (i) 1 mark for 2+3=5


each correct
r+ mode:
difference
 Primary function is reading
( minimum
 File pointer is at beginning of file two
differences
 if the file does not exist, it results in an error
should be
w+ mode: given)
 primary function is writing
 if the file does not exist, it creates a new file.
 If the file exists, previous data is overwritten
 File pointer is at the beginning of file
(ii)
½ mark for
correctly
opening and
closing files

½ mark for
correct try
and except
block

½ mark for
correct loop

1 mark for
correctly
copying data

[11]
½ mark for
correct
return
statement

½ mark for
correctly
opening and
closing files

½ mark for
correct try
and except
block

½ mark for
correct loop

½ mark for
OR correct if
(i) Text files: statement

 Extension is .txt 1 mark for


correctly
 Data is stored in ASCII format that is human readable
displaying
 Has EOL character that terminates each line of data data
stored in the text files

Binary Files
 Extension is .dat
 Data is stored in binary form (0s and 1s), that is not
human readable.

(ii)

[12]
Note: Any other correct logic may be marked
35 (i) Domain is a set of values from which an attribute can ½ mark for 1+4=5
correct
take value in each row. For example, roll no field can
definition
have only integer values and so its domain is a set of
½ mark for
integer values correct
example

(ii)

½ mark for
importing
correct
module

1 mark for
correct
connect()

½ mark for
correctly
accepting the
input
Note: Any other correct logic may be marked
1 ½ mark for
correctly

[13]
executing the
query

½ mark for
correctly
using
OR commit()

(i) All keys that have the properties to become a primary


key are candidate keys. The candidate keys that do not
become primary keys are alternate keys.
1 mark for
(ii) correct
difference

½ mark for
importing
correct
module

1 mark for
correct
connect()

1 mark for
correctly
executing
the query

½ mark for
correctly
using
fetchall()

1 mark for
correctly

[14]
displaying
data

[15]
KENDRIYA VIDYALAYA SANGATHAN AGRA REGION
FIRST PRE BOARD EXAMINATION (2023-24)
CLASS : XII TIME : 03 HOURS
SUBJECT : COMPUTER SCIENCE (083) MAXIMUM MARKS : 70

[ANSWER KEY / MARKING SCHEME]

SECTION A
(No marks for partially correct answers)
Q1 b) 1026 1
Q2 c) True 1
Q3 a) iai pa 1
Q4 a) list 1
Q5 c) [Link]( ) 1
Q6 d) None 1
Q7 c) t[3] = 300 1
Q8 d) $ 1
Q9 b) Optic Fiber 1
Q10 b) RJ45 1
Q11 a) select gender, count(*) form students having age >15; 1
Q12 b) UPDATE 1
Q13 c) 8, 24 1
Q14 b) bps 1
Q15 d) except 1
Q16 a) F = open(‘[Link]’, ‘read’) 1

d) Open(F) = ‘[Link]’
Q17 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

Q17 c) A is True but R is False 1

Page 1 of 7
Q18 a) Both A and R are true and R is the correct explanation for A 1
SECTION B
Q19 a) 2

i) Voice over Internet Protocol ii) eXtensible Markup Language ( ½ + ½ )


b) Telnet / SSH (1)
OR
½ Mark for each factor of comparison
Q20 L = [1,2,1,1,2,1,2,3,5,4,1,2,5,4,4,5] 2
D = {}
for x in L:
if x in D:
D[x]+=1
else:
D[x]=1
(½ Mark for each correction)
Q21 1 Mark for correct iterations 2
1 Mark for correct modifications
OR
1 Mark for taking input and returning True or False
1 Mark for comparing the string with its reverse
Q22 B#1 2
H#0
A#5
R#2
T#4
Q23 i. L[3].insert(2, 55) (1 mark) 2
ii. [Link](3) or [Link](-3) or [Link]([40,50,55,60]) (1 mark)
Q24 (i) ALTER TABLE Students ADD Phone INT; (1 mark) 1x2
(ii) ALTER TABLE Students ADD PRIMARY KEY (RollNo); (1 mark) =2
OR
(i) ALTER TABLE Books MODIFY rating DECIMAL(2,1); (1 mark)
(ii) ALTER TABLE Books DROP [COLUMN] pages; (1 mark)
Q25 3$3 2
3#3
6$4

Page 2 of 7
SECTION C
Q26 @@@NNew@MMen 3
Q27 i. 1x3
Name Salary =3
PV Sindhu Badminton
Saina Nehwal Badminton
Pankaj Advani Snooker
V Anand Hockey

ii.
sum(Salary)
22500

iii.
count(distinct Game)
5

Q28 def countFailedAttempts( ): 3


f = open(‘log_report.txt’)
lines = [Link]()
c=0
for line in lines:
if ‘failed’ in line: #if [Link]()[2] == ‘failed’
c+=1
[Link]()
return c #print(c)
OR
def countWords( ):
f = open(‘[Link]’)
words = [Link]().split()
c=0
for word in words:
if [Link](‘th’) or [Link](‘Th’): #if word[0:2] == ‘th’ or word[0:2] – ‘Th’
c+=1

Page 3 of 7
[Link]()
return c #print(c)
Q29 i. UPDATE Employees SET salary = salary + salry*0.1 WHERE gender = ‘F’; 3
ii. SELECT name, gender from Employees WHERE salary is NULL;
iii. DELETE from Employees WHERE dob<’1995-01-01’;

Q30 def Push_item(Inventory): 3


for item in Inventory:
if item[3]>100:
[Link](item)

def Pop_items():
try:
item = [Link]()
print(item)
except:
print(“Stack Empty”)

(or any other valid implementation)


SECTION D
Q31 i. SELECT gender, avg(Salary) from Employees group by gender; 4
ii. SELECT name, dept_name from Employees E and Departments D WHERE E.dept_id
= D.dept_id ORDER BY Salary DESC;
iii. SELECT max(Salary) FROM Employees WHERE dob>’1995-12-31’;
iv. SELECT dept_id, count(*) from Employees GROUP BY dept_id HAVING
count(*)>1;

Q32 def addPlayer(name, matches, goals): 4


player_data = [name, matches, goals]
with open('[Link]', 'a', newline='') as csvfile:
writer = [Link](csvfile)
[Link](player_data)

def highestAverage():

Page 4 of 7
max_average = 0
best_player = ''
with open('[Link]', 'r') as csvfile:
reader = [Link](csvfile)
next(reader) # Skip the header row if it exists
for row in reader:
name, matches, goals = row[0], int(row[1]), int(row[2])
if matches > 0:
average = goals / matches
if average > max_average:
max_average = average
best_player = name
if best_player:
print(best_player)
else:
print("No player data found in the CSV file.")

SECTION E
Q33 a) Tagore, as it has maximum number of computers. Housing the server here will reduce 1x5
the external traffic. =5
b) Firewall S
c) Ethernet Cable T R
25 m
90 m

A
75 m

d) Wi-Fi Router / Access Points


e) Switch, as hub will create the broadcast traffic.

Page 5 of 7
Q34 (i) 1 Mark for 1 difference point 2+3
=5

(ii)
import pickle
def search(app):
f = open(‘[Link]’, ‘rb’)
while True:
try:
obj = [Link](f)
if obj[0] == app:
print(obj)
break
except:
break
[Link]()

OR

(i) rb, rb+ will give error, while ab and wb+ modes will create the file (1/2 mark each)
(ii)
import pickle
def filterStudents(clas, sec):
fin = open('[Link]', 'rb')
fout = open('[Link]', 'wb')
while True:
try:
stu = [Link](fin)
if stu[2] == clas and stu[3] == sec:
[Link](stu, fout)
except:
break

Page 6 of 7
Q35 (i) ½ + ½ 1+4
=5
import [Link] as ms
conn = [Link](host="localhost",
user="heerakh",
passwd='happy',
db='sports')
cur = [Link]()
pid = int(input("Enter player ID : "))
pname = input("Enter name : ")
inn = int(input("Enter innings : "))
runs = int(input("Runs Scored : "))
wickets = int(input("Wickets : "))
query = f"insert into cricket values({pid}, '{pname}', {innings}, {runs}, {wickets})"
try:
[Link](query)
print("Row inserted")
except:
print("SQL Error")
[Link]()
OR

(i) ½ + ½

(ii)
import [Link] as ms
conn = [Link](host="localhost",
user="keshav",
passwd='karma',
db='sports')
cur = [Link]()
query = "select pname from cricket where innings>100"
[Link](query)
for row in [Link]():
print(row[0])
[Link]()

o——| End of Paper |——o

Page 7 of 7
PB23CS01

KENDRIYA VIDYALAYA SANGATHAN ERNAKULAM REGION


PRE-BOARD EXAMINATION 2023-24
COMPUTER SCIENCE (083)
Time allowed: 3 Hours Maximum Marks: 70
General Instructions:
 Please check 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 to 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.

[Link] QUESTION MARKS

SECTION - A
1 Which of the following is a keyword in Python?
a) true b) For c) pre-board d) False 1

2 What will be the output for the following Python statement?


print(20//3*2+(35//7.0))
1
a) 17.0 b) 17 c) 8.5 d) 8

3 In MYSQL database, if a table, BOOK has degree 8 and cardinality 7, and


another table, SALE has degree 4 and cardinality 7, what will be the degree and
1
cardinality of the Cartesian product of BOOK and SALE ?
a) 32 , 49 b) 12, 49 c) 12 ,14 d) 32,14
4 What is “ C “ stands in TCP/IP ?
1
a) Common b) Centre c)Control d) Coordinate
5 What is printed by the following statements?
ANIMAL={"dog":10,"tiger":5,"elephant":15,"Cow":3}
1
print("Tiger" not in ANIMAL)
a) True b)False c)Error d) None
6 Consider the following statements and choose the correct output from the given
options :
EXAM="COMPUTER SCIENCE" 1
print(EXAM[:12:-2])
a) EN b) CI c)SCIENCE d) ENCE
7 What will be the output of the following code ?
1
Tuple1=(10,)

1
Tuple2=Tuple1*2
print(Tuple2)
a) 20 b) (20,) c) (10,10) d) Error
8 Fill in the blanks:
The SQL keyword ---------------- is used in SQL expression to select records 1
based on patterns
9 What possible outcome will be produced when the following code is executed?
import random
value=[Link](0,3)
fruit=["APPLE","ORANGE","MANGO","GRAPE"]
for i in range(value):
print(fruit[i],end='##')
print()

a) APPLE##
1
b) APPLE#
ORANGE##

c) APPLE## ORANGE##

d) ORANGE##
MANGO##
APPLE##
10 Select the network device from the following, which connects, networks with
different protocols 1
a) Bridge b)Gateway c)Hub d) Router
11 State whether the following statement is TRUE or FALSE :
1
The value of the expression 4/3*(2-1) and 4/(3*(2-1)) is the same
12 In the relational models , cardinality actually refers to --------------
a) Number of tuples b) Number of attributes 1
c) Number of tables d) Number of constraints
13 Data structure STACK is also known as ----------- list
a)First In First Out b) First In Last Out 1
c)Last In First Out d) Last In Last Out
14 Which function is used to write a list of strings in a file?
1
a) writeline( ) b) writelines( ) c) write() d) writeall( )
15 Which of the following is NOT a guided communication medium?
a) Twisted pair cable b) Microwave 1
c) Coaxial cable d) Optical fibre
16 Which of the following function header is correct?
a) def fun(a=1,b):
b) def fun(a=1,b,c=2): 1
c) def fun(a=1,b=1,c=2):
d) def fun(a=1,b=1,c=2,d):
Q17 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

2
(d) A is false but R is True
17 Assertion ( A): In SQL, the aggregate function avg() calculates the average
value on a set of values and produces a single result.
Reason ( R): The aggregate functions are used to perform some fundamental 1
arithmetic tasks such as min(), max(), sum() etc

18 Assertion(A): Python overwrites an existing file or creates a non-


existing file when we open a file with ‘w’ mode.
1
Reason(R): a+ mode is used only for writing operations

SECTION - B
19 i) Expand the following :
a) SMTP b) VoIP
ii) Give one disadvantage of Star topology
1+1=2
OR
i) What is a web browser ?
ii) Define the term MAC Address
20 Rewrite the following code in Python after removing all syntax error(s) and
underline each correction done in the code .
30 = num
for k in range(0,num)
2
IF k%4==0 :
print(k*4)
Else:
print(k+3)
21 Write a function letter_count(lst) that takes a list of string and returns a
dictionary where the keys are the letters from lst and the values are the number
of times that letter appears in the lst.
For example: if the passed list, lst is :
lst=list(“apple”)
2
Then it should return a dictionary as {‘a’:1,’p’:2,’l’:1,’e’:1}
OR
Write a function max_length( ) ,that takes a list of string as argument and
display the longest string from the list.

22 Predict the output of the following code:

lst=[2,4,6,8,10]
for i in range(1,5):
2
lst[i-1]=lst[i]
for i in range(0,5):
print(lst[i],end=' ')

23 Consider the following list of elements and write Python statement to print the
output of each question.
elements=['apple',200,300,'red','blue','grapes'] 2
i) print(elements[3:5])
ii) print(elements[::-1])

3
OR
Consider the following list exam and write Python statement for the following
questions:
exam=[‘english’,’physics’,’chemistry’,’cs’,’biology’]
i) To insert subject “maths” as last element
ii) To display the list in reverse alphabetical order
24 Satheesh has created a database “school” and table “student”. Now he wants to
view all the databases present in his laptop. Help him to write SQL command
for that , also to view the structure of the table he created.

OR
2
Meera got confused with DDL and DML commands. Help her to select only
DML command from the given list of command.
UPDATE , DROP TABLE, SELECT , CREATE TABLE , INSERT INTO,
DELETE , USE
25 Predict the output for the following Python snippet

def calc(p,q=3):
ans=1
for x in range(q):
ans=ans*p 2
return ans
power=calc(3)
print(power,'9')
power=calc(3,2)
print(power,'27')
SECTION C
26 Predict the output of the Python code given below:
def calculate(str):
text=''
x=range(len(str)-1)
for i in x:
if str[i].isupper():
text+=str[i]
elif str[i].islower(): 3
text+=str[i+1]
else:
text+='@'
return text
start='Pre-board Exam'
final=calculate(start)
print(final)

4
27 Consider the following table DOCTOR given below and write the output of the
SQL Queries that follows :

D_ID D_NAME D_DEPT GENDER EXPERIENCE


101 JOSEPH ENT MALE 10
104 GUPTA MEDICINE MALE 12
106 SUMAN ORTHO FEMALE 7
111 HANEEF ENT MALE 12 3
123 DEEPTI CARDIOLOGY FEMALE 6
132 VEENA SKIN FEMALE 12
i) SELECT D_NAME FROM DOCTOR WHERE GENDER=MALE
AND EXPERIENCE=12 ;
ii) SELECT DISTINCT(D_DEPT) FROM DOCTOR ;
iii) SELECT D_NAME , EXPERIENCE FROM DOCTOR ORDER BY
EXPERIENCE ;

28 Write a function in Python to count the number of lines in a text fie ‘[Link]’
which start with an alphabet ‘T’ .
OR 3
Write a function in Python that count the number of “can” words present in a
text file “[Link]” .
29 Consider the following Table “TEACHER”

T_ID NAME AGE SEX DEPT D_O_JOIN SALARY


902 SANDEEP 45 M COMPUTER 10/10/2002 56000
813 SANGEETA 34 F HISTORY 24/9/2010 50000
771 JOEL 48 M ENGLISH 4/5/2001 67900
703 MANVITH 36 M MATHS 27/09/2012 48000
606 NEENA 32 F ENGLISH 23/5/2013 40000
537 ABHILASH 42 M MATHS 6/2/2006 47000
420 MUHSIN 49 M ENGLISH 8/3/2003 70450 3
412 SUBESH 52 M HINDI 10/11/1999 60500
345 RENJINI 36 F COMPUTER 27/4/2010 45000
218 DEEPTI 28 F HINDI 2/2/2016 40000
160 SHUBHAM 39 M SCIENCE 19/9/2011 45000

Based on the above table, Write SQL command for the following :
i) To show all information about the teacher of maths department
ii) To list name and department whose name starts with letter ‘M’
iii) To display all details of female teacher whose salary in between
35000 and 50000

5
30 Thushar received a message(string) that has upper case and lower-case alphabet.
He want to extract all the upper case letters separately .Help him to do his task
by performing the following user defined function in Python:
a) Push the upper case alphabets in the string into a STACK
3
b) Pop and display the content of the stack.
For example:
If the message is “All the Best for your Pre-board Examination”
The output should be : E P B A
SECTION D
31 Consider the table PRODUCT and CLIENT given below:
PRODUCT
PR_ID PR_NAME MANUFACTURER PRICE QTY
BS101 BATH SOAP PEARSE 45.00 25
SP210 SHAMPOO SUN SILK 320.00 10
SP235 SHAMPOO DOVE 455.00 15
BS120 BATH SOAP SANTOOR 36.00 10
TOOTH
TB310 COLGATE 48.00 15
BRUSH
FW422 FACE WASH DETOL 66.00 10
BS145 BATH SOAP DOVE 38.00 20
4

CLIENT
C_ID C_NAME CITY PR_ID
01 DREAM MART COCHIN BS101
02 SHOPRIX DELHI TB310
03 BIG BAZAR DELHI SP235
04 LIVE LIFE CHENNAI FW422
Write SQL Queries for the following:
i) Display the details of those clients whose city is DELHI
ii) Increase the Price of all Bath soap by 10
iii) Display the details of Products having the highest price
iv) Display the product name, price, client name and city with their
corresponding matching product Id.
32 Gupta is writing a program to create a csv file “[Link]” which will
contain user name and password for department entries. He has written the
following code . As a programmer, help him to successfully execute the given
task.
import ---------------- #statement 1
def add_emp(username,password):
4
f=open(‘[Link]’, ’----------‘) # statement 2
content=[Link](f)
[Link]([username,password])
[Link]()
def read_emp( ):
with open (‘[Link]’,’r’) as file:

6
content_reader=csv.-------------------(file) # statement 3
for row in content_reader:
print(row[0],row[1])
[Link]( )
add_emp(‘mohan’,’emp123#’)
add_emp(‘ravi’,’emp456#’)
read_emp() #statement 4
i) Name the module he should import in statement 1
ii) In which mode , Gupta should open the file to add record in to the
file ? (statement 2)
iii) Fill in the blank in statement 3 to read the record from a csv file
iv) What output will he obtain while executing statement 4 ?
SECTION E
33 Oxford college, in Delhi is starting up the network between its different wings.
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL
as shown below:

JUNIOR SENIOR ADMIN HOSTEL


The distance between various building is as follows:
ADMIN TO SENIOR 200 m
ADMIN TO JUNIOR 150 m
ADMIN TO HOSTEL 50 m
SENIOR TO JUNIOR 250 m
SENIOR TO HOSTEL 350 m
JUNIOR TO HOSTEL 350 m
Number of computer in each building is :
5
SENIOR 130
JUNIOR 80
ADMIN 160
HOSTEL 50

i) Suggest the cable layout of connections between the buildings.


ii) Suggest the most suitable place (i.e., building) to house the server of
this college, provide a suitable reason.
iii) Is there a requirement of a repeater in the given cable layout? Why/
Why not?
iv) Suggest the placement of hub/switch with justification.
v) The organisation also has inquiry office in another city about 50-60
km away in hilly region. Suggest the suitable transmission media to
interconnect to college and inquiry office out of the following:
a. Fiber optic cable
b. Microwave
c. Radiowave

7
34 i) What is Pickling or Serialization?
ii) A binary file “[Link]” has structure [employee id, employee
name, salary]. Write a function countrec() in Python that would read
contents of the file “[Link]” and display the details of those
employee whose salary is above 20000.

OR 2+3=5
i) What is the difference between ‘r’ and ‘rb’ mode in Python file ?
ii) A binary file “[Link]” has structure [admission_number,
Name, Percentage]. Write a function countrec() in Python that would
read contents of the file “[Link]” and display the details of
those students whose percentage is above 90. Also display number
of students scoring above 90%
35 i) What do you mean by a Primary key in RDBMS ?
ii) Complete the following database connectivity program by writing
the missing statements and performing the given query
import ------------------- as mysql # statement 1
con=mysql. ---------(host=’localhost’,user=’root’,passwd=’123’ ,
database=’student’) # statement 2
cursor=[Link]( )
[Link](--------------------------------) # statement 3
data=cursor. ----------------------------------- # statement 4
for rec in data:
print(rec)
[Link]( )
a) Complete the statement 1 by writing the name of package need to be
imported for database connectivity .
b) Complete the statement 2 by writing the name of method require to
create connection between Python and mysql.
c) Complete the statement 3 by writing the query to display those
students record whose mark is between 50 and 90 from table 1+4=5
“student”
d) Complete the statement 4 to retrieve all records from the result set.
OR
i) What is the difference between UNIQUE and PRIMARY KEY
constraints ?
ii) Maya has created a table named BOOK in MYSQL database,
LIBRARY
BNO(Book number )- integer
B_name(Name of the book) - string
Price (Price of one book) –integer

Note the following to establish connectivity between Python and


MySQL: Username – root, Password – writer,Host – localhost.

Maya, now wants to display the records of books whose price is


more than 250. Help Maya to write the program in Python

************************************

8
PB23CS01

KENDRIYA VIDYALAYA SANGATHAN


ERNAKULAM REGION
1st PRE BOARD EXAMINATION 2023 – 24

COMPUTER SCIENCE (083)


Class: XII
Time allowed: 3 Hours Maximum Marks: 70

MARKING SCHEME
[Link] QUESTION MARKS

SECTION - A
1 Which of the following is a keyword in Python ?
a) true b) For c) pre-board d) False 1

2 What will be the output for the following Python statement ?

print(20//3*2+(35//7.0))
1
a) 17.0 b) 17 c) 8.5 d) 8

3 In MYSQL database, if a table, BOOK has degree 8 and cardinality 7, and


another table, SALE has degree 4 and cardinality 7, what will be the degree and
1
cardinality of the Cartesian product of BOOK and SALE ?
b) 32 , 49 b) 12, 49 c) 12 ,14 d) 32,14
4 What is “ C “ stands in TCP/IP ?
1
a) Common b) Centre c)Control d) Coordinate
5 What is printed by the following statements ?
ANIMAL={"dog":10,"tiger":5,"elephant":15,"Cow":3}
1
print("Tiger" not in ANIMAL)
a) True b)False c)Error d) None
6 Consider the following statements and choose the correct output from the given
options :
EXAM="COMPUTER SCIENCE" 1
print(EXAM[:12:-2])
a) EN b) CI c)SCIENCE d) ENCE
7 What will be the output of the following code ?
Tuple1=(10,)
1
Tuple2=Tuple1*2
print(Tuple2)

1
a) 20 b) (20,) c) (10,10) d) Error
8 Fill in the blanks :
The SQL keyword ---------------- is used in SQL expression to select records
1
based on patterns
LIKE
9 What possible outcome will be produced when the following code is executed ?
import random
value=[Link](0,3)
fruit=["APPLE","ORANGE","MANGO","GRAPE"]
for i in range(value):
print(fruit[i],end='##')
print()

a) APPLE## 1
b) APPLE#
ORANGE##

c) APPLE## ORANGE##

d) ORANGE##
MANGO##
APPLE##
10 Select the network device from the following ,which connects , networks with
different protocols 1
a) Bridge b)Gateway c)Hub d) Router
11 State whether the following statement is TRUE or FALSE :
The value of the expression 4/3*(2-1) and 4/(3*(2-1)) is the same 1
TRUE
12 In the relational models , cardinality actually refers to --------------
a) Number of tuples b) Number of attributes 1
c) Number of tables d) Number of constraints
13 Data structure STACK is also known as ----------- list
a)First In First Out b) First In Last Out 1
c)Last In First Out d) Last In Last Out
14 Which function is used to write a list of strings in a file ?
1
a) Writeline( ) b) writelines( ) c) write() d) writeall( )
15 Which of the following is NOT a guided communication medium ?
a) Twisted pair cable b) Microwave 1
c)Coaxial cable d) Optical fibre
16 Which of the following function headers is correct ?
a) def fun(a=1,b):
b) def fun(a=1,b,c=2): 1
c) def fun(a=1,b=1,c=2):
d) def fun(a=1,b=1,c=2,d):
Q17 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

2
(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): In SQL, the aggregate function avg() calculates the average
value on a set of values and produces a single result.
Reason ( R): The aggregate functions are used to perform some fundamental
1
arithmetic tasks such as min(), max(), sum() etc

(b) Both A and R are true and R is not the correct explanation for A .
18 Assertion(A): Python overwrites an existing file or creates a non-
existing file when we open a file with ‘w’ mode.
Reason(R): a+ mode is used only for writing operations
1
(c) A is True but R is False

SECTION - B
19 i) Expand the following :
a) SMTP : Simple Mail Transfer Protocol
b) VoIP : Voice Over Internet Protocol
ii) Give one disadvantage of Star topology
Star topology has a single point of failure. If the central hub or switch fails,
the entire network will be down. This can be a major problem for networks
that require high availability. Or any other dis advantage.
OR
i) What is a web browser ?

A software application used to access information on the World Wide Web is 1+1=2
called a Web Browser. When a user requests some information, the web browser
fetches the data from a web server and then displays the webpage on the user's
screen.
ii) Define the term MAC Address

A MAC address (media access control address) is a 12-digit hexadecimal


number assigned to each device connected to the network. Primarily specified as
a unique identifier during device manufacturing, the MAC address is often
found on a device's network interface card (NIC).

20 Rewrite the following code in Python after removing all syntax error(s) and
underline each correction done in the code .
num=30
for k in range(0,num): ½ mark
if k%4==0 : each
print(k*4)
else:
print(k+3)
21 Write a function letter_count( lst) that takes a list of string and returns a
dictionary where the keys are the letters from lst and the values are the number
2
of times that letter appears in the lst.
For example: if the passed list is :

3
Lst=list(“apple”)
Then it should return a dictionary as {‘a’:1,’p’:2,’l’:1,’e’:1}
OR
Write a function max_length( ) ,that takes a list of string as argument and
display the longest string from the list.
Correct Program : 2 Marks

22 Predict the output of the following code:

lst=[2,4,6,8,10]

for i in range(1,5):

lst[i-1]=lst[i] 2
for i in range(0,5):

print(lst[i],end=' ')
output:
4 6 8 10 10

23 Consider the following list of elements and write Python statement to print the
output of each questions.
elements=['apple',200,300,'red','blue','grapes']
i) print(elements[3:5])

['red', 'blue']

ii) print(elements[::-1])

['grapes', 'blue', 'red', 300, 200, 'apple'] 2

OR
Consider the following list exam and write Python statement for the following
questions:
i) To insert subject “maths” as last element
[Link](‘maths’)
ii) To display the list in reverse alphabetical order
[Link](reverse=True)

24 Satheesh has created a database “school” and table “student”. Now he wants to
view all the databases present in his laptop. Help him to write SQL command
for that , also to view the structure of the table he created.

SHOW DATABASES
2
DESCRIBE/DESC student
OR

Meera got confused with DDL and DML commands. Help her to select only
DML command from the given list of command.

4
UPDATE , DROP TABLE, SELECT , CREATE TABLE , INSERT INTO,
DELETE , USE

DML: UPDATE,SELECT,INSERT INTO,DELETE


25 Predict the out put for the following Python snippet

def calc(p,q=3):
ans=1
for x in range(q):
ans=ans*p
return ans
power=calc(3) 2
print(power,'9')
power=calc(3,2)
print(power,'27')

OUTPUT:
27 9
9 27

SECTION C
26 Predict the output of the Python code given below:
def calculate(str):
text=''
x=range(len(str)-1)
for i in x:
if str[i].isupper():
text+=str[i]
elif str[i].islower():
text+=str[i+1]
3
else:
text+='@'
return text
start='Pre-board Exam'
final=calculate(start)
print(final)

OUTPUT:
Pe-@oard @Eam

5
27 Consider the following table DOCTOR given below and write the out put of the
SQL Queries that follows :

D_ID D_NAME D_DEPT GENDER EXPERIENCE


101 JOSEPH ENT MALE 10
104 GUPTA MEDICINE MALE 12
106 SUMAN ORTHO FEMALE 7
111 HANEEF ENT MALE 12
123 DEEPTI CARDIOLOGY FEMALE 6
132 VEENA SKIN FEMALE 12
i) SELECT D_NAME FROM DOCTOR WHERE GENDER=MALE
AND EXPERIENCE=12 ;
GUPTA
HANEEF 3
ii) SELECT DISTINCT(D_DEPT) FROM DOCTOR ;
DISTINCT(D_DEPT)
ENT
MEDICINE
ORTHO
CARDIOLOGY
SKIN
iii) SELECT D_NAME , EXPERIENCE FROM DOCTOR ORDER BY
EXPERIENCE;
D_NAME EXPERIENCE
DEEPTI 6
SUMAN 7
JOSEPH 10
GUPTA 12
HANEEF 12
VEENA 12

28 Write a function in Python to count the number of lines in a text fie ‘[Link]’
which start with an alphabet ‘T’ .

Correct function prototype ½ mark


Correct opening text file statement ½ mark
Correct logic 1 and ½ marks
Closing the file ½ mark 3

OR
Write a function in Python that count the number of “can” words present in a
text file “[Link]” .
def count_word():
count=0

6
f=open("[Link]","r")
contents=[Link]()
word=[Link]()
for i in word:
if i==’can’:
count+=1
print("Number of words in the File is :",count )
[Link]()
count_word()

Correct function prototype ½ mark


Correct opening text file statement ½ mark
Correct logic 1 and ½ marks
Closing the file ½ mark
29 Consider the following Table “TEACHER”

T_ID NAME AGE SEX DEPT D_O_JOIN SALARY


902 SANDEEP 45 M COMPUTER 10/10/2002 56000
813 SANGEETA 34 F HISTORY 24/9/2010 50000
771 JOEL 48 M ENGLISH 4/5/2001 67900
703 MANVITH 36 M MATHS 27/09/2012 48000
606 NEENA 32 F ENGLISH 23/5/2013 40000
537 ABHILASH 42 M MATHS 6/2/2006 47000
420 MUHSIN 49 M ENGLISH 8/3/2003 70450
412 SUBESH 52 M HINDI 10/11/1999 60500
1MARK
345 RENJINI 36 F COMPUTER 27/4/2010 45000
EACH
218 DEEPTI 28 F HINDI 2/2/2016 40000
160 SHUBHAM 39 M SCIENCE 19/9/2011 45000

Based on the above table , Write SQL command for the following :
i) To show all information about the teacher of maths department
SELECT * FROM TEACHER WHERE DEPT=’MATHS’;
ii) To list name and department whose name starts with letter ‘M’
SELECT NAME,DEPT FROM TEACHER WHERE NAME LIKE ‘M%’;
iii) To display all details of female teacher whose salary in between
35000 and 50000
SELECT * FROM TEACHER WHERE SEX=’F’ AND SALARY BETWEEN
35000 AND 50000 ;

30 Thushar received a message(string) that has upper case and lower case 1 mark
[Link] want to extract all the upper case letters separately .Help him to do for push
his task by performing the following user defined function in Python: (), 1 mark

7
a) Push the upper case alphabets in the string into a STACK for pop()
b) Pop and display the content of the stack. and 1
For example: mark for
If the message is “All the Best for your Pre-board Examination” displaying
The output should be: E P B A

Ans:
def push(s,ch):
[Link](ch)
def pop(s):
if s!=[]:
return [Link]()
else:
return None
string=“All the Best for your Pre-board Examination”
st=[]
for ch in string:
if [Link]():
push(st,ch)
while True:
item=pop(st)
if item!=None:
print(item,end= ‘ ‘)
else:
break
SECTION D
31 Consider the table PRODUCT and CLIENT given below:

PR_ID PR_NAME MANUFACTURER PRICE QTY


BS101 BATH SOAP PEARSE 45.00 25
SP210 SHAMPOO SUN SILK 320.00 10
SP235 SHAMPOO DOVE 455.00 15
BS120 BATH SOAP SANTOOR 36.00 10
TOOTH
TB310 COLGATE 48.00 15
BRUSH 1 mark
FW422 FACE WASH DETOL 66.00 10 each
BS145 BATH SOAP DOVE 38.00 20

PRODUCT
C_ID C_NAME CITY PR_ID
01 DREAM MART COCHIN BS101
02 SHOPRIX DELHI TB310
03 BIG BAZAR DELHI SP235
04 LIVE LIFE CHENNAI FW422

8
Write SQL Queries for the following :
i) Display the details of those clients whose city is DELHI
SELECT * FROM CLIENT WHERE CITY=’DELHI’;
ii) Increase the Price of all Bath soap by 10
UPDATE PRODUCT SET PRICE=PRICE+10 WHERE PR_NAME=’BATH
SOAP’;
iii) Display the details of Products having the highest price
SELECT * FROM PRODUCT WHERE PRICE=(SELECT MAX(PRICE)
FROM PRODUCT) ;
iv) Display the product name , price, client name and city with their
corresponding matching product Id .
SELECT PR_NAME , PRICE ,C_ID, CITY FROM PRODUCT , CLIENT
WHERE PRODUCT.PR_ID=CLIENT.PR_ID ;

32 Gupta is writing a program to create a csv file “[Link]” which will


contain user name and password for department entries. He has written the
following code. As a programmer, help him to successfully execute the given
task.

import ---------------- #statement 1


def add_emp(username,password):
f=open(‘[Link]’, ’----------‘) # statement 2
content=[Link](f)
[Link]([username,password])
[Link]()

def read_emp( ):
with open (‘[Link]’,’r’) as file:
content_reader=csv.-------------------(file) # statement 3
for row in content_reader:
print(row[0],row[1]) 4
[Link]( )
add_emp(‘mohan’,’emp123#’)
add_emp(‘ravi’,’emp456#’)
read_emp() #statement 4

i) Name the module he should import in statement 1


import csv
ii) In which mode , Gupta should open the file to add record in to the
file ? (statement 2)
Mode a
iii) Fill in the blank in statement 3 to read the record from a csv file
reader
iv) What output will he obtain while executing statement 4 ?
mohan emp123#
ravi emp456#

9
SECTION E
33 Oxford college, in Delhi is starting up the network between its different wings.
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL
as shown below:

JUNIOR SENIOR ADMIN HOSTEL

The distance between various building is as follows:

ADMIN TO SENIOR 200 m


ADMIN TO JUNIOR 150 m
ADMIN TO HOSTEL 50 m
SENIOR TO JUNIOR 250 m
SENIOR TO HOSTEL 350 m
JUNIOR TO HOSTEL 350 m

Number of computer in each building is :

SENIOR 130
1 mark
JUNIOR 80 each
ADMIN 160
HOSTEL 50

i) Suggest the cable layout of connections between the buildings.

ADMIN

SENIOR
JUNIOR HOSTEL

ii) Suggest the most suitable place (i.e., building) to house the server of
this college , provide a suitable reason.

ADMIN, as number of computers are more in ADMIN building

10
iii) Is there a requirement of a repeater in the given cable layout? Why/
Why not?

Yes, between ADMIN TO JUNIOR and ADMIN TO SENIOR distance is more


than 100 m.

iv) Suggest the placement of hub/switch with justification.

In all building as it is required to connect all computers in to a network.

v) The organisation also has inquiry office in another city about 50-60
km away in hilly region. Suggest the suitable transmission media to
interconnect to college and inquiry office out of the following :
a. Fiber optic cable
b. Microwave
c. Radiowave

Radio wave
34 i) What is Pickling or Serialization?
The process of converting Python object hierarchy into byte stream so that it can
be written into a file.
ii) A binary file “[Link]” has structure [employee id, employee
name, salary]. Write a function countrec() in Python that would read
contents of the file “[Link]” and display the details of those
employee whose salary is above 20000.

def countrec():
num=0
fobj=open(“[Link]”,’rb’)
try:
while True:
rec=[Link](fobj)
if rec[2]> 20000:
print(rec[0],rec[1],rec[2])
2+3=5
except:
[Link]()
OR

i) What is the difference between ‘r’ and ‘rb’ mode in Python file ?
r is used to read text files and rb is used to read binary files
ii) A binary file “[Link]” has structure [admission_number,
Name, Percentage]. Write a function countrec() in Python that would
read contents of the file “[Link]” and display the details of
those students whose percentage is above 90. Also display number of
students scoring above 90%
import pickle
def countrec():
fobj=open(‘[Link]’,’rb’)
num=0
try:

11
while True:
rec=[Link](fobj)
if rec[2]>90:
num=num+1
print(re[0],rec[1],rec[2])
except:
[Link]()
return num

35
i) What do you mean by a Primary key in RDBMS ?
In the relational model of databases, a primary key is a specific choice of a
minimal set of attributes that uniquely specify a tuple in a relation.
ii) Complete the following database connectivity program by writing
the missing statements and performing the given query
import ------------------- as mysql # statement 1
con=mysql. ---------(host=’localhost’,user=’root’,passwd=’123’ ,
database=’student’) # statement 2
cursor=[Link]( )
[Link](--------------------------------) # statement 3
data=cursor. ----------------------------------- # statement 4
for rec in data:
print(rec)
[Link]( )
i) Complete the statement 1 by writing the name of package
need to be imported for database connectivity .
[Link]
ii) Complete the statement 2 by writing the name of method
require to create connection between Python and mysql. 1+4=5
connect()
iii) Complete the statement 3 by writing the query to display
those students record whose mark is between 50 and 90
from table “student”
select * from student where mark between 50 and 90
iv) Complete the statement 4 to retrieve all records from the
result set.

[Link]()

OR

i) What is the difference between UNIQUE and PRIMARY KEY


constraints ?
The difference between a UNIQUE constraint and a Primary Key is
that per table may only have one Primary Key but may define more
than one UNIQUE constraints

12
ii) Maya has created a table named BOOKt in MYSQL database,

LIBRARY

BNO(Book number )- integer

B_name(Name of the book) - string

Price (Price of one book) –integer

Note the following to establish connectivity between Python and

MySQL:

Username - root

Password - writer

Host – localhost

Maya, now wants to display the records of books whose price is


more than 250. Help Maya to write the program in Python

1 mark each for creating connection object,


Creating cursor,
Writing sql command

13
क ीय िव ालय संगठन, जयपुर संभाग
Kendriya Vidyalaya Sangathan, Jaipur Region
थम ी-बोड परी ा 2023-24
First Pre-Board Exam 2023-24
क ा/Class: XII िवषय/Subject : Computer Science (083)
समय : 3 घंटे पूणाक/Max Marks: 70

सामा िनदश / General Instructions:


1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35
against part c only.

खंड / SECTION-A
सं / Question अंक /
Q. No. Marks
1. State True or False 1
“break keyword skips remaining part of an iteration in a loop and compiler goes to
starting of the loop and executes again”
2. Find the valid keyword from the following? 1
a) Student-Name b) False c) 3rdName d) P_no
3. What will be the output for the following Python statement? 1
X={‘Sunil’:190, ‘Raju’:10, ‘Karambir’:72, ‘Jeevan’:115}
print(‘Jeevan’ in X, 190 in X, sep=”#”)
(a)True#False (b) True#True
(c) False#True (d) False#False
4. Consider the given expression: 1
True and False or not True
Which of the following will be correct output if the given expression is evaluated?
(a) True (b) False
(b) (c) NONE (d) NULL
5. Select the correct output of the code: 1
a = "Python! is amazing!"
a = [Link]('!')
b = a[0] + "." + a[1] + "." + a[2]
print (b)
(a) Python!. is amazing!. (b) Python. is amazing.
(c) Python. ! is amazing.! (d) will show error
6. Which of the following mode in file opening statement overwrite the existing 1
content?
(a) a+ (b) r+
(c) w+ (d) None of the above
7. The attribute which have properties to be as referential key is known as. 1
(a) foreign key (b)alternate key
(c) candidate key (d) Both (a) and (c)
8. Which command is used to change some values in existing rows? 1
(a) CHANGE (b) MODIFY
(b) (c) ALTER (d) UPDATE
9. Which of the following statement(s) would give an error after executing the 1
following code?
Q="Humanity is the best quality" # Statement1
print(Q) # Statement2
Q="Indeed.” # Statement3
Q[0]= '#' # Statement4
Q=Q+"It is." # Statement5
(a) Statement 3 (b) Statement 4 (c)Statement 5 (d)Statement 4 and 5
10. p=150 1
def fn(q):
______________ #missing statement
p=p+q
fn(50)
print(p)
Which of the following statements should be given in the blank for #missing
statement if the output produced is 200
(a) global p=150 (b) global p
(c) p=150 (d) global q
11. Which function is used to split a line of string in list of words? 1
(a)split( ) (b) splt( )
(c) split_line( ) (d) all of these
12. What possible output(s) will be obtained when the following code is executed 1
import random
k=[Link](1,3)
fruits=[‘mango’, ‘banana’, ‘grapes’, ‘water melon’, ‘papaya’]
for j in range(k):
print(j, end=“*”)
(a) mango*banana*grapes (b) banana*grapes
(c) banana*grapes*watermelon (d) mango*grapes*papaya
13. Fill in the blank: 1
is a communication protocol responsible for sending emails.
(a) TCP (b) SMTP (c) PPP (d)HTTP
14. What will be the ouput when following expression be evaluated in Python? 1
print(21.5 // 4 + (8 + 3.0))
(a) 16 (b)14.0 (c) 15 (d) 15.5
15. Which of the following functions other than close() writes the buffer data to file 1
(a) push() (b) write() (c) writeBuffer() (d) flush()
16. To get counting of the returned rows, you may use……………. 1
(a) [Link] (b) [Link]
(c) [Link]() (d) [Link]()

Q17 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):- If the arguments in function call statement are provided in the format 1
parameter=argument, it is called keyword arguments.
Reasoning (R):- During a function call, the argument list first contain keyword
argument(s) followed by positional argument(s).
18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage with one 1
record on each line and each field is separated by comma.
Reason (R): The format is used to share data between cross platform as text editors are
available on all platforms.
खंड / SECTION-B
19. Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
Num=int(rawinput("Number greater than 10 :"))
sum=0
for i in range(10,Num,3)
sum+=1
if i%2=0:
print(i*2)
else:
print(i*3)
print(sum)
20. Write one advantage and one disadvantage of packet switching 2
OR
Which language is the most suitable language to create web pages?
21. (a)Given is a Python string : 1
X=”Kendriya Vidyalaya sangathan”
Write the output of: print(X[4:9]*2)
(b) Write the output of the python program code given below:
1
hello = {empname: "Ishan", address: ”New Delhi”, salary: 10000}
hello[salary] = 15000
hello[address] = "Delhi"
print([Link]())
22. Explain the use of GROUP BY clause in a Relational Database Management 2
System. Give example to support your answer.
23. (a) Write the full forms of the following: 2
(i)POP3 (ii) VoIP
(b) Define RJ-45?
24. Predict the output of the Python code given below: 2

OR
Predict the output of the Python code given below:
a=tuple()
a=a + tuple(‘Python’)
print(a)
print(len(a))
b=(10,20,30)
print(len(b))
25. Differentiate Where and Having clause in SQL with example. 2
OR
Define aggregate function and give example.
खंड / SECTION-C
26. (a) Consider the following tables – Employee and Office: 1+2
Table: Emp
Emp_Id Name Salary
E01 Lakshya 54000
E02 Ravi NULL
E03 Neeraj 32000
E04 Brijesh 42000

Table: dept
Emp_Id Dept DOJ
E01 Computer 05-SEP-2007
E02 Physics 05-JAN-2008
E03 Sports 30-DEC-2000
E04 English 05-SEP-2012

What will be the output of the following statement?


SELECT Name, Dept FROM Emp E, dept d WHERE E.Emp_Id=d.Emp_Id;

(b) Consider the following tables SCHOOL and ADMIN. Give the output the following SQL
queries:

i. SELECT Designation, COUNT (*) FROM Admin GROUP BY Designation HAVING


COUNT (*) <2;
ii. SELECT TEACHER FROM SCHOOL WHERE EXPERIENCE >12 ORDER BY
TEACHER DESC;

27. Write a method beginA() in Python to read lines from a text file [Link], and 3
display those lines, which are starting with ‘A’.
For example If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The beginA() function should display the output as:
An apple a day keeps the doctor away.
A marked difference will come in our country.
OR
A text file “[Link]” contains alphanumeric text. Write a program that reads this
text file and writes to another file “[Link]” entire file except the numbers or
digits in the file.
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations CLUB and 3
STUDENT given below:
Table : CLUB
COACHID CNAME AGE SPORTS DATEOFAPP PAY GENDER
1 KUKREJA 35 KARATE 27/03/1996 1000 M
2 RAVINA 34 KARATE 20/01/1998 1200 F
3 KARAN 34 SQUASH 19/02/1998 2000 M
4 TARUN 33 BASKETBALL 01/01/1998 1500 M
5 ZUBIN 36 SWIMMING 12/01/1998 750 M
6 KATAKI 36 SWIMMING 24/02/1998 800 F
7 ANKITA 39 SQUASH 20/02/1998 2200 F
8 ZAREEN 37 KARATE 22/02/1998 1100 F
9 KUSH 41 SWIMMING 13/01/1998 900 M
10 SHAILYA 37 BASKETBALL 19/02/1998 1700 M

Table : STUDENT
COACHID SNAME STIPEND STREAM MARKS GRADE CLASS
1 KARAN 400.00 MEDICAL 78.5 B 12B
12 VINNET 450.00 COMMERCE 89.2 A 11C
13 VIVEK 300.00 COMMERCE 68.6 C 12C
4 DHRUV 350.00 HUMANITIES 73.1 B 12C
15 MOHIT 500.00 NONMEDICAL 90.6 A 11A
6 ANUJ 400.00 MEDICAL 75.4 B 12B
17 ABHAY 250.00 HUMANITIES 64.4 C 11A
18 PAYAL 450.00 NONMEDICAL 88.5 A 12A
19 DIKSHA 500.00 NONMEDICAL 92.0 A 12A
10 RISHIKA 300.00 COMMERCE 67.5 C 12C

i) SELECT SPORTS, MIN(PAY) FROM Club Group by SPORTS ;


ii) SELECT MAX(DATEOFAPP), MIN(DATEOFAPP) FROM CLUB;
iii) SELECT CNAME, PAY, [Link], SPORTS FROM CLUB C, STUDENT S WHERE
[Link] =[Link] AND PAY>=1500;
iv) SELECT SName, CNAME FROM Student S, CLUB C
WHERE Gender =’F’ AND [Link]=[Link];
(b) Write SQL command to list all databases.
29. Write a function shiftn(L,n), where L is a list of integers and n is an integer. The function 3
should return a list after shifting n number of elements to the left.
Example: If the list initially contains [2, 15, 3, 14, 7, 9, 19, 6, 1, 10] and n=2
then function should return [3, 14, 7, 9, 19, 6, 1, 10, 2, 15]
If the list initially contains [2, 15, 3, 14, 7, 9, 19, 6, 1, 10] and n=4
then function should return [7, 9, 19, 6, 1, 10, 2, 15, 3, 14]
30. A nested list contains the data of visitors in a museum. Each of the inner lists contains 3
the following data of a visitor:
[V_no (int), Date (string), Name (string), Gender (String M/F), Age (int)]
Write the following user defined functions to perform given operations on the stack
named "status":
(i) Push_element(Visitors) - To Push an object containing Gender of visitor who
are in the age range of 15 to 20.
(ii) Pop_element() - To Pop the objects from the stack and count and display the
number of Male and Female entries in the stack. Also, display “Done” when
there are no elements in the stack.
For example: If the list of Visitors contains:
[['305', "10/11/2022", “Geeta”,"F”, 35],
['306', "10/11/2022", “Arham”,"M”, 15],
['307', "11/11/2022", “David”,"M”, 18],
['308', "11/11/2022", “Madhuri”,"F”, 17],
['309', "11/11/2022", “Sikandar”,"M”, 13]]
The stack should contain
F
M
M
The output should be:
Female: 1
Male: 2
Done

OR
Write a function in Python, Push(EventDetails) where , EventDetails is a dictionary
containing the number of persons attending the events– {EventName :
NumberOfPersons}. The function should push the names of those events in the stack
named ‘BigEvents’ which have number of persons greater than 200. Also display the
count of elements pushed on to the stack.
For example:
If the dictionary contains the following data:
EventDetails ={"Marriage":300, "Graduation Party":1500, "Birthday Party":80,
"Get together" :150}

The stack should contain:


Marriage
Graduation Party

The output should be:


The count of elements in the stack is 2

खंड / SECTION-D
31. Ripunjay is planning to connect its Delhi Campus with its head office at Goregaon. Its 5*1
Delhi Campus is spread across an area of approx. 1 square kilometers consisting of 3
blocks. HR, Acad and Adm. You as a network expert have to suggest answers to the five
queries (i) to (v) raised by them.

Goregaon Delhi Campus


Office Finance
HR

Adm Acad

Shortest distances between various blocks


HR to Adm 120m
HR to Acad 75m
Acad to Adm 130m
HR to Finance 70m
Finance to Adm 90m
Goregaon to Delhi Campus 50 km
Number of computers installed at various blocks
Block Number of Computers
HR 250
Adm 30
Acad 70
Finance 20
Goregaon 20

(i) Suggest the most suitable block in the Delhi Campus to host the server. Give a
suitable reason with your suggestion.
(ii) Suggest the cable layout among the various blocks within the Delhi Campus
for connecting the blocks.
(iii) Suggest the placement of the following devices with appropriate reasons:

a. Switch / Hub
b. Repeater

(iv) Suggest a protocol that shall be needed to provide Video Conferencing solution
between Goregaon Office and Delhi campus.
(v) Suggest the type of network to connect Goregaon Office and Delhi campus.

32. (a) Write the output of the code given below: 2+3
a=5
def add(b=2):
global a
a=a+b
print(a,'#',b)
return a
b=add(a)
print(a,'#',b)
b=add(b)
print(a,'#',b)

(b) The code given below inserts the following record in the table Employee:
EmpNo – integer Name – string
Department – string Salary – integer
Note the following to establish connectivity between Python and MYSQL:
 Username is root
 Password is brick
 The table exists in a MYSQL database named organization.
 The details (EmpNo, Name, Department and Salary) 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

import [Link] as mysqldef


sql_data():
con=[Link](host="localhost",user="root",password="brick",
database="organization")
mycursor=_______________________ #Statement 1
eno=int(input("Enter Employee number :: "))
name=input("Enter Name :: ")
dept=input("Enter Department name :: ")
sal=int(input("Enter Salary :: "))
query="insert into student values({},'{}',{},{})".format(eno,name,dept,sal)
_______________________ #Statement 2
_______________________ # Statement 3
print("Data Added successfully")

OR
(a) Predict the output of the code given below:
a="Give me a glass of water!"
n =len(a)
b=” ”
for i in range(0, n):
if a[i] >= 'a' and a[i] <= 'k':
b = b + a[i].upper()
elif (a[i] >= 'l' and a[i] <= 'z'):
b = b + a[i-1]
elif a[i].isupper():
b = b + a[i].lower()
else:
b = b + '#'
print(b)

(a) The code given below reads the following record from the table named items and
displays only those records who have price greater than 100:
ItemNo –integer
Name – string
Price – integer

Note the following to establish connectivity between Python and MYSQL:


 Username is root
 Password is epic
 The table exists in a MYSQL database named store.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of items with price greater
than 100.
Statement 3 - to read the complete result of the query (records whose marks are
greater than 75) into the object named data, from thetable studentin the
database.

import [Link] as mysqlcon


def sql_data():
con=[Link](host="localhost",user="root",password="epic",
database="store")
mycursor= #Statement1
print("Items with price greater than 100 are :")
________________________ #Statement2
data= _#Statement3
for i in data:
print(i)
33. a. What is the advantage of using a csv file for permanent storage? 2+3
b. Write a python program to create a csv file [Link] and write 10 records in it Dvdid,
dvd_name, qty, price. Display those dvd details whose dvd price is more than 25.
OR
a. Write difference between a binary file and a csv file.
b. Write a Program in Python that defines and calls the following user defined
functions:
(i) add() – To accept and add data of an employee to a CSV file ‘[Link]’. Each
record consists of a list with fieldelements as eid, ename and salary to
store empid, emp name and emp salary respectively.
(ii) search()- To display the records of the emp whose salary is more than 10000.
खंड / SECTION-E
34. Mubarak creates a table Items with a set of records to maintain the details of items. 1+1+
After creation of the table, he has entered data of 5 items in the table. 2

Table: items
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpener 23 60 8 31-JUN-09
Classic
2003 Balls 22 50 25 01-FEB-10
2002 Gel Pen Premium 21 150 12 24-FEB-10
2006 Gel Pen Classic 21 250 20 11-MAR-09
2001 Eraser Small 22 220 6 19-JAN-09
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as Primary
key.
(ii) If 3 columns are added and 2 rows are deleted from the table , what will be the
new degree and cardinality of the above table?
(iii) Write the statements to:
a. Insert the following record into the table as (2024, Point Pen, 20, 11, 350,
15-NOV-2022).
b. Increase the rate of the items by 2% whose name ends with ‘c’.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of items having rate greater than equal to 10.
b. Add a column REMARKS in the table with datatype as varchar with 50
characters
35. Anamika is a Python programmer. She has written a code and created a binary file
[Link] with sid, sname and marks. The file contains 10 records.
She now has to update a record based on the sid entered by the user and update the
marks. The updated record is then to be written in the file [Link]. The records which
are not to be updated also have to be written to the file [Link]. If the sid is not found,
an appropriate message should to be displayed.
As a Python expert, help him to complete the following code based on requirement given
above:
import ……………. #Statement 1
def update_data():
rec={}
fin=open("[Link]","rb")
fout=open("______________________") #Statement 2
found=False
eid=int(input("Enter student id to update their marks :: "))
while True:
try:
rec= #Statement 3
if rec["student id"]==sid:
found=True
rec["marks"]=int(input("Enter new marks:: "))
pickle. #Statement 4
except:
break
if found==True:
print("The marks of student id ",sid," has been updated.")
else:
print("No student with such id is not found")
[Link]()
[Link]()
(i) Which module should be imported in the program? (Statement1)
(ii) Write the correct statement required to open a temporary file named
[Link]. (Statement 2)
(iii) Which statement should Anamika fill in Statement 3 to read the data from the
binary file, [Link] and in Statement 4 towrite the updated data in the file,
[Link]?
KENDRIYA VIDYALAYA SANGATHAN, JAIPUR REGION
I-Pre Board Examination 2023-24
Class-12 Subject: Computer Science (083)
Answer Key

SECTION-A
QN. Answer of Question
1. False 1
2. False 1
3. True#False 1
4. False 1
5. (b)Python. is amazing. 1
6. (c) w+ 1
7. (a) foreign key 1
8. (d) UPDATE 1
9. (b) Statement 4 1
10 (b) global p 1
.
11 (a) split() 1
.
12 (a) mango*banana*grapes 1
13 (b) SMTP 1
14 Ans. (a) 16 1
15 (d) flush() 1
16 (a) [Link] 1
17 Ans. (c) A is True but R is False 1
18 Ans: (a) Both A and R are true and R is the correct explanation for A 1
SECTION-B
19. Num=int(input("Number greater than 10 :")) 2
sum=0
for i in range(10,Num,3):
Sum+=1
if i%2==0:
print(i*2)
else:
__print(i*3)
print(Sum)
20. 1 mark for any correct advantage and disadvantage each 2
OR
Hyper Text Markup Language. Yes it has pre defined tags.
21. (a) Ans: riya riya 1
(b) dict_keys(['empname', 'address', 'salary'])
1
22. Ans. GROUP BY clause is used to get the summary data based on one or more 2
groups. The groups can be formed on one or more columns. For example, the
GROUP BY query will be used to count the number of employees in each
department, or to get the department wise total salaries.
SELECT COUNT(ENAME), SUM(SALARY), DEPT
FROM EMPLOYEES
GROUP BY DEPT;
23. (i) Post office Protocol 3 2
(ii) Voice over Internet Protocol
(b) Ans: Registered Jack-45 is used as connector to connect ethernet cable
to ethernet Port in the CPU
24. Ans: 2
20000 # 100.0
100.0 $ 200
2000 # 200.0
100.0 $ 200.0
1000.0 # 100.0
100.0 $ 200.0
OR

Ans:
(‘Python’)
6
3
25. Ans. Where” clause is used to filter the records from a table 2
that is based on a specified condition, then the “Having” clause
is used to filter the record from the groups based on the
specified condition. OR

Ans. Aggregate function are group functions which works on group of


rows. Examples are sum(), min(), max(), avg(), count() etc.
SECTION-C
26. a) 1+2
Name Dept
Lakshya Computer
Ravi Physics
Neeraj Sports
Brijesh English

b)

(i) Vice principal 1

(ii) YASHRAJ
UMESH

27. Ans: 3
def beginA():
f=open(‘[Link]’)
l=[Link]()
for i in l:
if i[0]==’A’ or i[0]= =’a’:
#or if i[0] in [“A”,”a’]
print(i)
[Link]()
OR
fr=open(“[Link]”)
fw=open(“[Link]”, ‘w’)
d=[Link]()
for i in d:
if not [Link]():
[Link](i)
[Link]()
[Link]()
½ marks each for correct piece of code
28. Ans. (a) 3
i) Give 1 mark each correct output
SPORTS MIN(PAY)
Karate 1000
Squash 2000
Basketball 1500
Swimming 750
ii) Give 1 mark each correct output
MAX(DATEOFAPP), MIN(DATEOFAPP)
24/02/1998 27/03/1996

iii) Give 1 mark each correct output


CNAME PAY [Link] SPORTS
TARUN 1500 4 BASKETBALL
SHAILYA 1700 10 BASKETBALL

iv) Give 1 mark each correct output


SNAME CNAME
ANUJ KATAKI
b) Show databases;
29. def shiftn(L,n): 3
return L[n:]+L[:n]
30. visitors=[['305', '10/11/2022', 'Geeta','F', 15],['306', '10/11/2022', 'Arham','M', 3
15],\['307', "11/11/2022", 'David','M', 18],['308', "11/11/2022", 'Madhuri','F',
17]]
status=[]
def Push_Element(visitors):
global status
for i in visitors:
if i[4]>=15 and i[4]<=20:
[Link](i[3])

def Pop_Element():
global status
m,f=0,0
if status!=[]:
r=[Link]()
if r== ‘F’:
f+=1
else:
m+=1
else:
print(“Female :”,f)
print(“Male :”,m)
print("Done")

OR
def Push(EventDetails):
BigEvents=[]
count=0
for i in EventDetails:
if EventDetails[i]>200:
[Link](i)
count+=1
print(“The count of elements in the stack is”,count)
SECTION-D
31. Ans. (i) HR because it has maximum number of computers 5*1
(ii) Star topology with HR at centre (any appropriate block diagram)
(iii) Switch need to be installed in each of the block repeater where distance is
greater than 100m
(iv) VoIP
(v) WAN
32. Ans. (a) 2+3
10 # 5
10 # 10
20 # 10
20 # 20

Ans: (b)
Statement 1:
[Link]()
Statement 2:
[Link](query)
Statement 3:
[Link]()
OR

Ans. (a) gIiE# E#A#GgAas# F# AaEe#


Ans. (b)
Statement 1: [Link]()
Statement 2: [Link](“select Name from items where price>100”)
Statement 3: [Link]()
33. (a) Advantage of a csv file: 2+3
It is human readable – can be opened in Excel and Notepad applications
It is just like text file
(b) ½ marks for each correct piece of code.

OR
Ans: Difference between binary file and csv file: (Any one difference may be
given) Binary file:
Binary csv
Extension is .dat Extension is .csv
Not human readable Human readable
Stores data in the form of 0s and 1s Stores data like a text file
CSV file

Program:
import csv
def add():
fout=open("[Link]","a",newline='\n')
wr=[Link](fout)
fid=int(input("Enter Emp Id :: "))
fname=input("Enter Emp name :: ")
fprice=int(input("Enter psalary :: "))
FD=[eid,ename,salary]
[Link](FD)
[Link]()
def search():
fin=open("[Link]","r",newline='\n')
data=[Link](fin)
found=False
print("The Details are")
for i in data:
if int(i[2])>10000:
found=True
print(i[0],i[1],i[2])
if found==False:
print("Record not found")
[Link]()
add()
print("Now displaying")
search()
SECTION-E
34. Ans. (i) ItemNo 1+1
(ii) Cardinality=3 and Degree=9 +2
(iii)
a) Insert into items values (2024, ‘point pen’, 20, 11, 350, ‘2022-NOV-15’);
b) Update items
Set rate=rate+(rate*0.02)
Where Item like ‘%c’;
OR
iii) Delete From items where rate>=10;
b) Alter table items Add column (Remarks Varchar(50));

35. (i) pickle 1


(ii) fout=open(‘[Link]’, ‘wb’) 1
(iii) [Link](fin) 1
(iv) [Link](rec,fout) 1
क ीय िव ालय संगठन, जयपुर संभाग
Kendriya Vidyalaya Sangathan, Jaipur Region
थम ी-बोड परी ा 2023-24
First Pre-Board Exam 2023-24
क ा/Class: XII िवषय/Subject : Computer Science (083)
समय : 3 घंटे पूणाक/Max Marks: 70

सामा िनदश / General Instructions:


1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions (1 to 18) carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions (19 to 25) carrying 02 marks each.
5. Section C has 05 Short Answer type questions (26 to 30) carrying 03 marks each.
6. Section D has 02 Long Answer type questions (31 to 32) carrying 04 marks each.
7. Section E has 03 questions (33 to 35) carrying 05 marks each.
8. All programming questions are to be answered using Python Language only.

खंड / SECTION-A
सं / Question अंक /
Q. No. Marks
1. State True or False 1
“ continue keyword is not a jump statement in a loop.”
2. Fill in the blank: 1
command is used to remove a column from a table in SQL.
(a)update (b)remove (c) alter (d)drop
3. Given the following dictionaries 1
dict_stud = {"rno" : "53", "name" : ‘Rajveer Singh’}
dict_mark = {"Accts" : 87, "English" : 65}
Which statement will merge the contents of both dictionaries in dict_stud?
(a) dict_stud + dict_mark (b) dict_stud.add(dict_mark)
(c) dict_stud.merge(dict_mark) (d) dict_stud.update(dict_mark)
4. 1
print(True or not True and False)
Choose one option from the following that will be the correct output after executing
the above python expression.
a) False b) True c) or d) not
5. Which of the following commands will delete the rows of table? 1
(a) DROP command (b) DELETE Command
(c) REMOVE Command (d) ALTER Command
6. Fill in the blank: 1
______is the first page that normally view at a website.
(a) First Page (b) Master Page (c) Home Page (d) Login Page
7. When a Python function does not have return statement then what it returns? 1
(a) int (b) float (c) None (d)Give Error
8. Select the correct output of the code: 1
>>> a= "Year 2022 at All the best"
>>> a = [Link]('2')
>>> a = a[0] + ". " + a[1] + ". " + a[3]

1|Page
>>> print (a)
(a) Year . 0. at All the best (b) Year 0. at All the best
(c) Year . 022. at All the best (d) Year . 0. at all the best
9. Which of the following statement(s) would give an error after executing the 1
following code?
S="Welcome to class XII" # Statement 1
print(S) #Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5

(a) Statement 3 (b) Statement 4


(c ) Statement 5 (d) Statement 4 and 5
10. What will the following expression be evaluated to in Python? 1
print(2**3**2)
a) 64 b) 256 c) 512 d) 32
11. Which is the smallest network? 1
a) WAN (b) LAN
c) MAN (d) PAN
12. Write the possible outputs(s) when this code is executed? 1
import random
n=[Link](0,3)
color=[“Y”,”W”,”B”,”R”]
for i in range (1,n):
print(color[i], end=”*”)
print( )
a) R * b) W*
W* B*
B*
c) W* W* d) Y*
B* B* W* W*
B* B* B*
13. Which Python approach is used for object serialization in handling of Binary File? 1
(a) Pickling (b) Un-pickling
(c) Merging (d) None of these
14. Fill in the blank: 1
_______Keyword is used to obtain Non-duplicated values in a SELECT query.
(a) ALL (b) DISTINCT (c) SET (d) HAVING
15. Fill in the blank: 1
_______ is the way of connecting the networking devices.
16. Which of the following is not valid cursor function while performing database 1
operations using python. Here Mycur is the cursor object?
(a) [Link]() (b) [Link]()
(c) [Link](n) (d) [Link]()
Q17 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): A variable declared as global inside a function is visible with 1
changes made to it outside the function.

2|Page
Reasoning (R): All variables declared outside are not visible inside a function
till they are redeclared with global keyword.

18. Assertion (A): A binary file in python is used to store collection objects like lists and 1
dictionaries that can be later retrieved in their original form using pickle module.
Reasoning (R): A binary files are just like normal text files and can be read
using a text editor like notepad.
खंड / SECTION-B
19. (i) Write the full forms of the following: (a) IP (b) URL 1+1=
(ii) What is the use of VoIP? 2
OR
(i) Mention one advantage of Star Topology.
(ii) Mention one difference between a Hub and switch in networking.
20. Observe the following Python code very carefully and rewrite it after removing all 2
syntactical errors with each correction underlined.
Define reverse(num):
rev = 0
While num > 0:
rem == num %10
rev = rev*10 + rem
num = num//10
return rev
print(reverse(1234))
21. Write a function INDEX_LIST(L), where L is the list of elements passed as argument to 2
the function. The function returns another list named ‘indexList’ that stores the
indices of all Non-Zero Elements of L.
For example:
If L contains: [2, 0, 5, 0, 1, 0, 0]

The indexList will have: [0,2,4]


OR
Write definition of a function Count_How_Many(Data, item) to count and display number
of times the value of item is present in the list Data. (Note: don’t use the count() function)
For example :
If the Data contains [101,102,107,105,102,103,104,102] and item contains 102
The function should display 102 found 3 Times.
22. Predict the output of the Python code given below: 2
def foo(s1,s2):
l1=[ ]
l2=[ ]
for x in s1:
[Link](x)
for x in s2:
[Link](x)
return l1,l2
a,b=foo( "HAPPY",'BIRTHDAY')
print(a,b)
23. Write the Python statement for each of the following tasks: 1+1=2
(i) str="PYTHON@LANGUAGE"
To print the above string from index 2 onwards using a single statement.
(ii) To initialize an empty dictionary named as d using BUILT_IN
fuctions/ methods only.
OR
Write the Python statement for each of the following tasks using BUILT_IN fuctions/
methods only:

3|Page
(i) s=”LANGUAGE"
To convert the above string into list.
(ii) To initialize an empty tuple named as t.
24. A MySQL table, sales have 10 rows with many columns, one column name is 2
DISCOUNT. Following queries were executed on sales table.
SELECT COUNT(*) FROM sales;
COUNT(*)
10
SELECT COUNT(DISCOUNT) FROM sales;
COUNT( DISCOUNT )
6
Write a statement to explain as to why there is a difference in result of both queries.
OR
Write commands to open database ‘KVS’ and show all tables in this database. And
display design/schema/structure of the table EMPLOYEE which is inside this
database. And display all the records of table EMPLOYEE.
25. Predict the output of the Python code given below: 2
data = [20,19,19,17,20,19,17,20]
d = {}
for x in data:
if x in d:
d[x]=d[x]+1
else:
d[x]=1
print(d)
खंड / SECTION-C
26. Write the output of the code given below: 3
def change(Line):
alpha=str()
digi=str()
for ch in Line:
if([Link]()):
if([Link]()):
alpha=alpha+[Link]()
elif([Link]()):
alpha=alpha+[Link]()
elif([Link]()):
alpha=alpha+ch+ch
print(Line)
print(alpha)
change("Vande 0 Bharat 9 Train 1")
27. Write the output of queries (i) to (iii) based on the table Sportsclub given below: 1*3=
Table: Sportsclub 3
playerid pname sports country rating salary
10001 PELE SOCCER BRAZIL A 50000
10002 FEDERER TENNIS SWEDEN A 20000
10003 VIRAT CRICKET INDIA A 15000
10004 SANIA TENNIS INDIA B 5000
10005 NEERAJ ATHLETICS INDIA A 12000
10006 BOLT ATHLETICS JAMAICA A 8000
10007 PAUL SNOOKER USA B 10000
(i) SELECT DISTINCT sports FROM Sportsclub;
(ii) SELECT sports, MAX(salary) FROM Sportsclub GROUP BY sports

4|Page
HAVING sports<>'SNOOKER';
(iii) SELECT pname, sports, salary FROM Sportsclub WHERE
country='INDIA' ORDER BY salary DESC;
28. A pre-existing text file [Link] has some words written in it. Write a python function 3
displaywords( ) that will print all the words that are having length greater than 3.
If the contents of file is :
A man always wants to strive higher in his life
He wants to be perfect.

The output should be: always wants strive higher life wants perfect.

OR
Write a method count_lines( ) in Python to read lines from text file ‘[Link]’ and
display the total number of line in file and lines which are ending with ‘y’ alphabet and
not ending with ‘y’ separately.

Example: If the file content is as follows:


An apple in a day keeps the doctor away.
We should aware for everyone’s safety and security.
India is one of the biggest country in word.
The count_lines( ) function should display the output as:
The number of lines in file are: 3
The number of lines ending with alphabet ‘y’ are: 2
The number of lines not ending with alphabet ‘y’ are: 1

29. Monika is a senior clerk in a MNC. She created a table ‘Salary’ with a set of records to 1*3=
keep ready for tax calculation. After creation of the table, she has entered data of 5 3
employees in the table.

Based on the table given above write the SQL Queries:


(i) Display the Emp_Name and Gross salary of each employee. (Gross=
basic+da+hra+nps)

(ii) Increase the DA by 3% of respective basic salary of all employees.

(iii) Delete the Attribute emp_desig from the table.

30. A list of numbers is used to populate the contents of a stack using a function push(stack, 3
data) where stack is an empty list and data is the list of [Link] function should
push all the numbers that are even to the stack.
Also write the function pop(stack) that removes and returns the top element of the
stack on its each call.

Also write the function calls.

5|Page
खंड / SECTION-D
31. Write the SQL queries (i) to (iv) based on the relations SCHOOL and ADMIN given below: 1*4=4

Write SQL queries for the following:


i) Display total periods subjectwise.
ii) Display minimum experience and maximum code from relation SCHOOL.
iii)Display teachername, gender by joining both tables on the basis of CODE attribute for
the designation “COORDINATOR.
iv) Display the total number of different subjects in school relation.
32. Write a Program in Python that defines and calls the following user defined functions: 4
Add_New():
To accept record of Player and add to ‘[Link]’ file. The record of player
consists P_id, P_name and P_runs in form of python list.
Display_Record():
To read the records of Player from ‘[Link]’ file and display the record of
player whose runs are more than 5000.
खंड / SECTION-E
33 Hitech Info Limited wants to set up their computer network in Bangalore based 1*5=5
. campus having four buildings. Each block has a number of computers that are required
to be connected for ease of communication, resource sharing and data security.
You as a network expert have to suggest answers to these parts (a) to (e) raised by them.

DEVELOPMENT HUMANRESOURCE
PMENT
KVS
LOGISTICS ADM
RO

Shortest distances between various blocks


Block DEVELOPMENT to Block HUMANRESOURCE -- 50 m
Block DEVELOPMENT to Block ADM-- 75 m

6|Page
Block DEVELOPMENT to Block LOGISTICS-- 80 m
Block HUMANRESOURCE to Block ADM-- 110 m
Block ADM to Block LOGISTICS 140 m

Number of computers installed at various blocks


Block Number of Computers
DEVELOPMENT -- 105
HUMANRESOURCE-- 130
ADM-- 190
LOGISTICS-- 55

a) Suggest the most suitable block to host the server. Justify your answer.
b) Suggest the wired medium and Draw the cable layout (Block to Block) to
economically connect various blocks.
c)Suggest the placement of the following devices with justification:
(i) Hub/Switch (ii)Repeater
d)Suggest the device that should be placed in the Server building so that they can
connect to Internet Service Provider to avail Internet Services.
e) Suggest the high-speed wired communication medium between Bangalore Campus
and Mysore campus to establish a data network.
34 (i) What is CSV means? Which packages/modules are imported for using Binary Files 2+3= 5
. and CSV files in Python?

(ii) Abhay have a binary file called [Link] containing book information- B_id, B_name
and B_price of each book.
[[B_id, B_name, B_price],[B_id, B_name, B_price],…]
Write the user defined function Trace_Book() to show the records of books having the
price less than 1000. In case there is no book having price <1000 the function displays
message “Such Record not found”.

OR
(i) Write any two difference between text file and binary file.

(ii)Mayur is a student, who have a binary file called [Link] containing employee
information- sid, name and age of each student.
[sid, name , age]
Write the user defined function Get_Stud() to display the name and age of those student
who have a age greater than 18 year. In case there is no student having age >18 the
function displays message “There is no student who is greater than 18 year”.
35 (i) What is the difference between a Candidate Key and an Alternate Key. 1+4=5
.
(ii) Virat has created a table named TRAVELS in MySQL:
Tour_ID – string
Destination – String
Geo_Cond– String
Distance – integer (In KM)

Note the following to establish connectivity between Python and MYSQL:


 Username is root
 Password is bharat
 The table TRAVELS exists in a MYSQL database named TOUR.
 The details Tour_ID, Destination, Geo_Cond and Distance are to be accepted from the
user.

Virat wants to display All Records of TRAVELS relation whose Geographical condition

7|Page
is hilly area and distance less than 1000 KM. Help Virat to write program in python.

OR

(i) Write one point of difference between PRIMARY KEY and UNIQUE KEY in SQL.

(ii) Aarya has created a table named Emp in MySQL:


EmpNo – integer
EmpName – string
Age– integer
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
 Username - root
 Password - tiger
 Host - localhost
 The Emp table exists in a MYSQL database named company.
 The details of Emp table (EmpNo, EmpName, Age and Salary)
Aarya wants to display All Records of Emp relation whose age is greater than 55. Help
Aarya to write program in python.

----------------*------------*------------------

8|Page
KENDRIYA VIDYALAYA SANGATHAN, JAIPUR REGION
PreBoard-I Examination 2023-24
Class-XII
Subject: Computer Science (083)
Answer Key

SECTION-A
QN. Answer of Question
1. Ans. False 1
2. Ans. (c) alter 1
3. Ans: (d) dict_student.update(dict_marks) 1
4. Ans. (b) True 1
5. Ans. (b) DELETE Command 1
6. Ans: (c) HomePage 1
7. Ans. (c) None 1
8. Ans. (a) Year . 0. at All the best 1
9. Ans. (b) Statement 4 1
10. Ans. (c) 512 1
11. Ans: (d) PAN 1
12. Ans. (b) W* 1
B*
13. Ans. (a) Pickling 1
14. Ans. (b) DISTNICT 1
15. Ans. Topology 1
16. Ans. (a) [Link]() 1
17. Ans. (c) A is True but R is False 1
18. Ans. (c) A is True but R is False 1
SECTION-B
19. (i) (a) IP-Internet Protocol 2
(b) URL- Uniform Resource Locator (1/2 mark for each)
(ii)VoIP is used to transfer audio (voice) and video over internet(1 mark)
OR
(i) Advantage: The network remains operational even if one of the nodes
stopsworking. (1 mark for any ONE advantage)
(ii)
Hub Switch
Hub is a passive Device Switch is an active device
Hub broadcasts messages to all Switch sends the messages to
nodes intended node.
Or any other valid difference between the two.
(1 mark for ANY ONE difference)
20. def reverse(num): 1+1
rev = 0 =2
while num > 0:
rem == num %10
rev = rev*10 + rem
num = num//10
return rev
print(reverse(1234))
(½ Mark for each correction up to any 4 corrections)

1|Page
21. 1+1=
2

OR
def Count_How_Many(Data, item):
count=0
for n in Data:
if(n==item):
count+=1
print(item, " found ", count, "times")

d=[101,102,107,105,102,103,104,102]
i=102
Count_How_Many(d,i)
or any other correct logic
22. ['H', 'A', 'P', 'P', 'Y'] ['B', 'I', 'R', 'T', 'H', 'D', 'A', 'Y'] 2
23. (i) str="PYTHON@LANGUAGE" 2
print(str[2: : ])
(ii) d=dict( )
OR
(i) s=”LANGUAGE"
l=list(s)
(ii) t=tuple( )
24. COUNT(*) returns the count of all rows in the table, whereas COUNT 2
(COLUMN_NAME) is used with Column_Name passed as argument and
counts the number of non-NULL values in a column that is given as
argument. Here discount column is having 4 rows with NULLvalues.
OR
Use KVS; (1/2 mark)
Show Tables; (1/2 mark)
Desc EMPLOYEE;
(1/2 MARK)
Select * from EMPLOYEE; (1/2 MARK)

25. {20: 3, 19: 3, 17: 2} 2


SECTION-C
26. Vande 0 Bharat 9 Train 1 3
vANDE00bHARAT99tRAIN11
(3 marks for correct answer. Partial marks may be given for partially
correct answer.)
27. (1 mark for each correct output) 1*3
=3
2|Page
(i)
sports
SOCCER
TENNIS
CRICKET
ATHLETICS
SNOOKER
ii)
Sports MAX(salary)
SOCCER 50000
TENNIS 20000
CRICKET 15000
ATHLETICS 12000
iii)
pname sports salary
VIRAT CRICKET 15000
NEERAJ ATHLETICS 12000
SANIA TENNIS 5000
28. def displaywords (): 3
file = open('[Link]','r')
st=[Link]()
lst=[Link]()
for k in lst:
if len[k] >3:
print(k, end=” “)
[Link]()
displaywords ()# Call the displaywords
(½ mark for function header, 1 mark for opening file,
1 mark for correct for loop and condition,½ mark for closing file)
OR
def count_lines():
f=open("[Link]",'r')
rows=[Link]()
end_y=not_y=0

for rec in rows:


if(rec[-1]=='y'):
end_y+=1
else:
not_y+=1
print("The number of lines in file are", len(rows))
print("The number of lines ending with alphabet ‘y’ are:",end_y)
print("The number of lines not ending with alphabet ‘y’ are:",not_y)
count_lines()
#call the function
(½ mark for function header, 1 mark for opening file,
1 mark for correct for loop and condition,½ mark for closing file)
29. (i) SELECT EMP_NAME, BASIC+DA+HRA+NPS AS “GROSS SALARY” FROM 1*3
SALARY; =3
(ii)UPDATE SALARY SET DA=DA+0.03*BASIC;
(iii)ALTER TABLE SALARY DROP COLUMN EMP_DESIG;

3|Page
30. data = [1,2,3,4,5,6,7,8] 3
stack = []
def push(stack, data):
for x in data:
if x % 2 == 0:
[Link](x)
def pop(stack):
if len(stack)==0:
return "stack empty"
else:
return [Link]()
push(stack, data)
print(pop(stack))
(½ mark should be deducted for all incorrect syntax. Full marks to beawarded
for any other logic that produces the correct result.)
SECTION-D
31. i)SELECT SUM (PERIODS), SUBJECT FROM SCHOOL GROUP BY SUBJECT ; 1*4
ii) SELECT MIN(EXPERIENCE), MAX(CODE) FROM SCHOOL; =4
iii)SELECT TEACHERNAME, GENDER FROM SCHOOL, ADMIN WHERE
DESIGNATION = ‘COORDINATOR’ AND [Link]=[Link];
iv)SELECT COUNT(DISTINCT SUBJECT) FROM SCHOOL;
(1 mark for each correct query)
32. import csv 2+2=
def Add_New(): 4
fout=open("[Link] ","a",newline='\n')
wr=[Link](fout)
P_id=int(input("Enter Player Id :: "))
P_name=input("Enter Player name :: ")
P_runs=int(input("Enter price :: "))
playerlist=[P-id,P_name,P_runs]
[Link](playerlist)
[Link]()
def Display_Record():
fin=open("[Link] ","r")
data=[Link](fin)
found=False
print("The Player Records are: ")
for Rec in data:
if int(rec[2])>5000:
found=True
print(rec[0],rec[1],rec[2])
if found==False:
print("Such Record not found")
Add_New():
Display_Record():
(½ mark for importing csv module)
(1 ½marks each for correct definition of Add_New() and
Display_Record ())
(½ mark for function call statements )

4|Page
SECTION-E
33. i) ADM Block 1*5=
Justification- It has maximum number of computers. Reduce traffic. 5
ii) wired medium is ethernet cables. Following bus (cable cost efficient) or star
with ADM as centre (network traffic efficient)

DEVELOPMENT HUMANRESOURCE

LOGISTICS ADM

iii) (a) Switches in all the blocks since the computers need to be connected to
the network.
(b) Repeaters between ADM and HUMANRESOURCE block& ADM and Logistics
block. The reason being the distance is morethan 100m.
iv) Modem should be placed in the Server building
v) Optical Fiber cable connection
34. (i) Full form of CSV is Coma Separated Value. 2+3=
pickle module is used for Binary files and csv module is used for 5
importing csv files. (1+ ½ +½)
ii)import pickle
def Trace_Book():
fopen=open("[Link] ","r")
data=[Link](fopen)
found=False
print("The Book Records are: ")
for Rec in data:
if (rec[2])<1000:
found=True
print(rec[0],rec[1],rec[2])
if found==False:
print("Such Record not found")
Trace_Book():
OR
(i) (1 mark for each difference between text file and binary file)
(ii)import pickle
def Get_Stud():
Total = 0
Count_rec = 0
Count_age = 0
with open(“ [Link]”, “ rb”) as F:
while True:
try:
R=[Link](f)
Count_rec = Count_rec+1
Total = Total+R[2]
if R[2] > 18:
print (R[1],“is of Age :”,R[2])
Count_age + = 1
except:
break
if Count_age = =0 :
print(“There is no student who is greater than 18 year”)
5|Page
Get_Stud()
35. (i)Any one difference: 1+4=
CANDIDATE KEY ALTERNATE KEY 5
All attributes in a relation thathave potential to All the leftover candidate keys
become a Primary key after selecting the primary key

(ii)
import [Link] as BD
def Emp_Database():
con=[Link](host="localhost", user="root", password="bharat",
database="TOUR")
BDcursor=[Link]()
print("Travels at Hilly Area and the distance more than 1000 KM.:")
[Link]("select * from TRAVELS WHERE Geo_Cond =’hilly area"
AND Distance<1000)
TravelRec= [Link]()
for rec in TravelRec:
print(rec)
OR
(i)Any one difference:
PRIMARY KEY UNIQUE KEY
There can be only one primary There can be more than one unique
key in a table keys in a table
The primary key cannot have null Unique can have null values
values

(ii)
import [Link] as cnt
def Emp_Database():
con=[Link](host="localhost", user="root", password="tiger",
database="company")
mycursor= [Link]()
print("Display Employee whose age is more than 55 years:")
[Link]("select * from Emp where age>55”)
EmpRec= [Link]()
for rec in EmpRec:
print(rec)

6|Page
क ीय िव ालय संगठन, जयपुर संभाग
Kendriya Vidyalaya Sangathan, Jaipur Region
थम ी-बोड परी ा 2023-24
First Pre-Board Exam 2023-24
क ा/Class: XII िवषय/Subject : Computer Science (083)
समय : 3 घंटे पूणाक/Max Marks: 70

सामा िनदश / General Instructions:


 Please check 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 to 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
सं / Question अंक /
Q. No. Marks
1 State True or False: 1
“Lexical unit is the smallest unit of any programming language”

2 Fill in the blank: 1


command is used to remove the tuple from the table in SQL.
(a) update (b) remove
(c) alter (d) delete

3 What will be the output of the following statement: 1


print ((30.0 // 4 + (8 + 3.0))
a. 14.75 b. 18.0
c. -18.0 d. Error

4 Select the correct output of the code: 1


>>> Str= "BHASHA SANGAM @ 75"
>>> S=[Link](" ")
>>> print(S)
a. (@ 75' 'BHASHA', ' ', 'SANGAM,)
b. ('BHASHA', ' @', 'SANGAM , 75')
c. ('', ' ', 'BHASHA SANGAM @ 75')
d. ('BHASHA', ' ', 'SANGAM @ 75')

[1]
5 In MYSQL database, if a table, Emp has degree 10 and cardinality 5, and 1
another table, Dept has degree 5 and cardinality 10, what will be the degree
and cardinality of the Cartesian product of Emp and Dept ?
a. 50,15 b. 15,50
c. 50,50 d. 15,15

6 Ankur wants to transfer songs from his mobile phone to his laptop. He uses 1
Bluetooth Technology to connect two devices. Which type of network will be
formed in this case?
a. PAN b. LAN
c. MAN d. WAN
7 Give the output: 1
dic1={‘r’:’red’,’g’:’green’,’b’:’blue’}
for i in dic1:
print (i, end =’ ’)
a. r g b b. R G B
c. R B G d. red green blue
8 Consider the statements given below and then choose the correct output 1
from the given options:
MN="Bharat @G20"
print(MN[-[Link]-2])
Options:
a. rt@2 b. 2@tr

c. @G20 d. 02G@

9 Which of the following statement(s) would give an error after 1


executing the following code?

S="Welcome to KVS RO JAIPUR " # Statement 1


print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '$' # Statement 4
S=S+"Thank you" # Statement 5

(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5

[2]
10 What possible outputs(s) will be obtained when the following code is 1
executed?
import random
Signal=['Stop','Wait','Go']
for K in range (2,0,-1):
R=[Link](K)
print(Signal[R], end='#')
options:
a. Stop#Go#
b. Wait#Stop#
c. Go#Stop#
d. Go#Wait#

11 Fill in the blank: 1


…………….is a communication methodology designed to deliver emails over
Internet protocol.
a. VIOP
b. SMTP
c. PPP
d. HTTP
12 Consider the code given below and find correct output: 1

x=5
def function1():
global x
y=x+x*2
print(y,end=”,”)
x=7
function1()
print(x)

Output:

a. 21 , 7
b. 15 , 5
c. 21 , 5
d. 15, 7

[3]
13 State whether the following statement is True or False: 1
Exception handling can be done for both user-defined and built-in exceptions.

14 Which of the following statements is FALSE in reference to MySQL? 1


a. It is an RDBMS.
b. It is case sensitive.
c. It is an open source.
d. It is ideal for both small and large applications.

15 Fill in the blank: 1

In case of switching, each information or message to be

transmitted between sender and receiver is broken down into smaller pieces.

16 Which method is used to move the file pointer to a specified position.? 1

[Link]()
[Link]()
[Link]()
[Link]()

Q17 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 1
Assertion(A): Access mode ‘a’ opens a file for appending.

Reasoning(R): The file pointer is at the end of the file if the file exists.

18 1
Assertion(A): A function is block of organized and reusable code that is used to
perform a single, related action.

Reasoning(R): Function provides better modularity for your application and a high

degree of code reusability.

[4]
खंड / SECTION B

19 (i) Expand the following terms: 1+1=


2
SMTP, IMAP
(ii) Give one difference between Active Hub and Passive Hub.

OR
(i) Define the term Protocol with respect to networks.
(ii) How is Hub different from Switch?

20 Harsh has written a code to input a number and find a table of any number. His 2
code is having errors. Rewrite the correct code and underline the corrections
made.

def table():
n=int(("Enter number which table U need: ")
for i in (1,11):
print("Table of Enter no=”,i*i)
Table()

21 Write a function countMy(SUBJECT) in Python, that takes the dictionary, 2


SUBJECT as an argument and displays the names (in uppercase) of the
subjects whose names are longer than 5 characters. For example, Consider the
following dictionary
SUBJECT={1:"Hindi",2:"Physics",3:"Chemistry",4:"cs",5:"Math"}
The output should be:
HINDI
PHYSICS
CHEMISTRY
OR
Write a function, lenLines(STRING), that takes a string as an argument

and returns a tuple containing length of each word of a string.


For example, if the string is " let us learn Python", the
tuple will have ( 3, 2, 5, 6)

[5]
22 Predict the output of the following code: 2

tuple1 = (11,22,33,44,55,66)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%2==0 :
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)

23 Write the Python statement for each of the following tasks using BUILT-IN 1+1=
functions/methods only: 2

(i) To insert an element 100 at the Second position, in the list L1.
(ii) To check whether all the characters in the string S1 are digits or not.
OR
How the pop( ) function is different from remove( ) function working with
list in python ? Explain with example.

24 Pooja wrote a query in SQL for student table but she is not getting desired result 2
select * from student where fee = NULL;
Rewrite the above query so that she gets desired result

OR

Categorize the following commands as DDL or DML:


INSERT, ALTER, DROP, DELETE, UPDATE, CREATE

25 Predict the output of the following code: 2

def Diff(N1,N2):
if N1<N2:
return N1-N2
else:
return N2*N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')

[6]
खंड / SECTION C

26 Predict the output of the Python code given below: 3

def my_city (L,N):


for i in range(0,N):
if len(L)>4:
L[i]=L[i]+L[i]
else:
L[i]=L[i]
sub=['Delhi','Jaipur','Agra','Surat','Mumbai','Bhopal']
my_city(sub,6)
print(sub)

27 Write the outputs of the SQL queries (a) to (c) based on the relation Furniture 1*3
=
No Itemname Type Dateofstock Price Discount 3
1 White lotus Double Bed 23/02/2002 30000 25
2 Pink feather Baby Cot 20/01/2002 7000 20
3 Dolphin Baby Cot 19/02/2002 9500 20
4 Decent Office 01/01/2002 25000 30
Table
5 Comfort Double Bed 12/01/2002 25000 25
Zone
6 Donald Baby Cot 24/02/2002 6500 15
7 Royal finish Office 20/02/2002 18000 30
Table
8 Royal tiger Sofa 22/02/2002 31000 30
9 Econo sitting Sofa 13/12/2001 9500 25
10 paradise Dining 19/02/2002 11500 25
Table
11 Wood Double Bed 23/03/2003 25000 25
Comfort
12 Old Fox Sofa 20/02/2003 17000 20
13 Micky Baby Cot 21/02/2003 7500 15

(a) SELECT Itemname FROM Furniture WHERE Type="Double Bed";


(b) SELECT Dateofstock FROM Furniture WHERE Type="Sofa" order by Dateofstock;
(c) SELECT Type,sum(Price) FROM Furniture group by Type;

28 Define a function SHOWWORD () in python to read lines from a text file 3


[Link], and display those words, whose length is less than 5.
OR
Write a user defined function in python that displays the number of lines starting
with 'H' in the file [Link]

[7]
29 Consider the table Emp given below: 1*3=
3
Table : EMP

E_ID Name Desig Salary Allowance

E01 Ramesh Manager 80000 5400

E02 Kailash Clerk NULL 2400

E03 Rudra Supervisor 48000 NULL

E04 Sakila Clerk 30000 2000

E05 Prachi Supervisor NULL 2800

Based on the given table, write SQL queries for the following:
(i) Increase the salary by 10% of employees whose allowance is known.
(ii) Display Name and Total Salary (sum of Salary and Allowance) of all
employees. The column heading ‘Total Salary’ should also be
displayed.
(iii) Delete the record of employess who have salary greater than 40000.

30. [Link] has created a list of elements. Help him to write a program in 3
python with functions, PushEl (S,element) and PopEl (S) to add a new
element and delete an element from a List of element named ‘S’ considering
them to act as push and pop operations of the Stack data structure . Push the
element into the stack only when the element is divisible by 4.

For eg:if L=[2,5,6,8,24,32]

then stack content will be

32 <- Top

24

[8]
खंड / SECTION D
31 Consider the doctor and patient table and write the output of (i) to (iv) 1*4=
4
Doctor
docid Dname Specialization Outdoor
D1 MANISH PHYSICIAN MONDAY
D2 PARESH EYE FRIDAY
D3 KUMAR ENT SATURDAY
D4 AKASH ENT TUESDAY

Patient
Pid Pname did Date_visit
P1 Lal singh D2 2022-04-25
P2 Arjun D1 2022-05-05
P3 Narender D4 2022-03-13
P4 Mehul D3 2022-07-20
P5 Naveen D2 2022-05-18
P6 Amit D1 2022-01-22

(I) select count(*) from patient where date_visit like ‘%2_’;


(II) select specialization ,count(*) from doctor group by specialization;
(III) select [Link], [Link] from doctor a, patient b where [Link]=[Link];
(IV) select dname from doctor,patient where docid=did and pname=’Arjun’;
32 A csv file “ [Link]” contains record of student in following order 4
[rollno, name, sub1,sub2,sub3,total]

Initially student total field is empty string as example data is given below
['1', 'Anil', '40', '34', '90', '']
['2', 'Sohan', '78', '34', '90', '']
['3', 'Kamal', '40', '45', '9', '']

A another file “[Link]” is created which reads records of “[Link]” and copy all
records after calculating total of marks into [Link]. The contents of [Link]
should be
['1', 'Anil', '40', '34', '90', '164']
['2', 'Sohan', '78', '34', '90', '202']
['3', 'Kamal', '40', '45', '9', '94']

(a) Define a function createcsv() that will create the [Link] file with the
sample data given above.

(b) Define a function copycsv() that reads the [Link] and copy the same
data after calculating total field into [Link] file.

[9]
खंड / SECTION E

33 M/s Computer Solutions is a professional consultancy company. The company is 1*5=


planning to set up their new offices in India with its hub at Hyderabad. As a 5
network adviser, you have to understand their requirement and suggest them the
best available solutions. Their queries are mentioned as (i) to (v) below.

Physical locations of the blocks of M/s Computer Solutions

HR BLOCK MEETING BLOCK

FINANCE BLOCK

Block to block distance (in m)


Block (From) Block (To) Distance
HR Block MEETING 110
HR Block Finance 40
MEETING Finance 80
Expected number of computers
Block Computers
HR 25
Finance 120
MEETING 90

(i) Which will be the most appropriate block, where M/s Computer
Solutions should plan to install their server?
(ii) Draw a block to block cable layout to connect all the buildings in the
most appropriate manner for efficient communication.
(iii) What will be the best possible connectivity out of the following, you will
suggest to connect the new set up of offices in Bengalore with its
London based office.
 Satellite Link
 Infrared
 Ethernet
(iv) Which of the following device will be suggested by you to connect each
computer in each of the buildings?
 Switch
 Modem
 Gateway
(v) Company is planning to connect its offices in Hyderabad which is less
than 1 km. Which type of network will be formed?

[10]
34 2+3=
5
(i) Differentiate between rb+ and wb+ file modes in Python.
(ii) Consider a binary file “[Link]” containing details such as
(empno, ename, salary). Write a python function to
display details of those employees who are earning between 20000 and
30000 (both values inclusive).

OR
(i) Differentiate between dump and load functions in binary files?

(ii) Write a Python function in Python to search the details of the employees
[name, designation, salary] whose salary is greater than 5000. The
records are stored in the file “[Link]”. consider each record in the file
[Link] as a list containing name, designation and salary.

35 (i) How many candidate key and primary key a table can have in a Database? 1+4=
5
(ii) Manish wants to write a program in Python to create the following table
named “EMP” in MYSQL database, ORGANISATION:
Eno (Employee No )- integer , Ename (Employee Name) - string
Edept (Employee Department)-string, Sal (salary)-integer
Note the following to establish connectivity between Python and MySQL:
Username – root , Password – admin , Host - localhost
The values of fields eno, ename, edept and Sal has to be accepted from the
user. Help Manish to write the program in Python to insert record in the above
table..

OR
(i) Differentiate between degree & cardinality key in RDBMS?

(iii) Vihaan wants to write a program in Python to create the following table
named “EMP” in MYSQL database, ORGANISATION:
Eno (Employee No )- integer , Ename (Employee Name) - string
Edept (Employee Department)-string, Sal (salary)-integer
Note the following to establish connectivity between Python and MySQL:
Username – root , Password – admin , Host - localhost
Help Vihaan to write the program in Python to Alter the above table with new
column named Bonus (int).

[11]
Class XII

Computer Science (083)

Marking Scheme

Time Allowed: 3 hours MM: 70

Ques Question and Answers Distribution Total


No of Marks Marks

SECTION A
1 True 1 mark for 1
correct
answer

2 Option d 1 mark for 1


correct
delete answer

3 Option b 1 mark for 1


correct
18 answer

4 Option d 1 mark for 1


(‘BHASA’, ‘ ‘, ‘SANGAM@75’) correct
answer

5 Option b 1 mark for 1


correct
15,50 answer

6 Option a 1 mark for 1


correct
PAN answer

7 Option a 1 mark for 1


correct
r g b answer

8 Option b 1 mark for 1


2@tr correct
answer

[1]
9 Option b 1 mark for 1
correct
Statement 4 answer

10 Option b 1 mark for 1


correct
Wait#Stop# answer

11 Option b 1 mark for 1


correct
SMTP answer

12 Option a 1 mark for 1


correct
21 answer
7
13 True 1 mark for 1
correct
answer

14 Option b 1 mark for 1


correct
It is case sensitive answer

15 Packet 1 mark for 1


correct
answer

16 Option c 1 mark for 1


correct
seek() answer

17 Option a 1 mark for 1


Both A and R are true but R is the correct explanation for A correct
answer

[2]
18 Option a 1 mark for 1
correct
Both A and R are true but R is the correct explanation for A answer

SECTION B
19 (i) ½ mark for 1+1=2
each correct
SMTP – Simple Mail Transfer Protocol expansion

IMAP – Internet Message Access Protocol

(ii)
1 mark for
Active hubs amplify the incoming electric signal, whereas passive hubs any one
do not amplify the electric signal. (Any other valid difference may be
correct
considered)
difference

OR
(i) A network protocol is an established set of rules that determine 1 mark for
how data is transmitted between different devices in the same correct
network.
definition
(ii) Hub is an electronic device that connects several nodes to form
a network and redirect the received information to all the nodes 1 mark for
in a broadcast mode. Whereas Switch is an intelligent device
any one
that connects several nodes to form a network and redirect the
received information only to the intended node(s). correct
difference
(Any other valid difference may be considered)

20 def table (): ½ mark for 2


n=int (input ("Enter number which table U need: "))
each
for i in range (1,11):
print ("able of Enter no=",i* n) correction
table () made

[3]
21 ½ mark for 2
correct
SUBJECT={1:"Hindi",2:"Physics",3:"Chemistry",4:"CS",5:"MATH"}
function
def countMy (SUBJECT): header
for S in [Link]():
½ mark for
if len(S)>5:
correct loop
print([Link]())
½ mark for
countMy()
correct if
statement

½ mark for
displaying
the output

OR
½ mark for
correct
def lenLines (STRING):
function
t=()
header
L=[Link]()
for line in L: ½ mark for
using split()
length=len(line)
½ mark for
t=t+(length,)
adding to
return t
tuple

½ mark for
return
statement

Note: Any other correct logic may be marked


22 1½ mark for 2
(22, 44, 66)
each correct
digit
½ mark for
parenthesis

[4]
23 (i) [Link](1,100) 1 mark for 1+1=2
each correct
(ii) [Link]() statement

OR
pop() function removes the last value and returns the same.

>>>L=[10,20,30,20] 1 mark for


correct
>>> [Link] () difference
and 1 mark
20 for suitable
The remove() method removes the first matching value from the list. example

>>>[Link] (20)

[10, 30, 20]

24 SQL Command to add primary key: 2 mark for 2


correct
select * from student where fee IS NULL Command

OR
1 mark for
DDL : CREATE, ALTER DROP each correct
DDL & DML
DML: INSERT UPDATE DELETE Categorized
commands

25 ½ mark for 2
-22 # 756 # -9 # 230 #
each correct
number and ½
mark for each
correct #
symbol
SECTION C
26 ['DelhiDelhi', 'JaipurJaipur', 'AgraAgra', 'SuratSurat', 'MumbaiMumbai', ½ mark for 3
'BhopalBhopal'] each correct
output

[5]
27 1*3=3
1 mark for
each
(a) (b) (c) correct
Item Name Dateofstock Type Sum(Price)
White lotus 13/12/2001 Double Bed 80000 output.
Comfort Zone 22/02/2002 Baby Cot 30500
Wood Comfort 20/02/2003 Office Table 43000
Sofa 57500
Dining Table 11500
28 def SHOWWORD () : (½ Mark for 3
c=0 opening the file)
file=open(‘[Link],'r') (½ Mark for
line = [Link]() reading line
and/or splitting)
word = [Link]()
(½ Mark for
for w in word: checking
if len(w)<5: condition)
print( w) (½ Mark for
[Link]() printing word)

OR
def count H( ):
f = open (“[Link]” , “r” )
lines =0
L=f. readlines ()
for i in L:
if i [0]== ‘H’:
lines +=1
print (“No. of lines are: “ , lines)
29 (i) 1 mark for 1*3=3
each correct
UPDATE EMP
query
SET Salary=Salary + Salary*0.10
WHERE Allowance IS NOT NULL;

(ii) SELECT Name, Salary + Allowance AS


"Total Salary" FROM EMP;

(iii)
DELETE FROM EMP
WHERE Salary>40000;
[6]
30 N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38] 1½ marks for 3
def PUSHEl(S,N):
[Link](N)
each Push
def POPEl(S): and Pop
if S!=[]: operation
return [Link]()
else:
return None
ST=[]
for k in N:
if k%4==0:
PUSHEl(ST,k)
while True:
if ST!=[]:
print(POPEl(ST),end=" ")
else:
break

SECTION D
31 (i) 1 mark for 1*4=4
each correct
3
output

(ii)
1
1
2
(iii)
Dname Pname
PARESH Lal singh
MANISH Arjun
AKASH Narender
KUMAR Mehul
PARESH Naveen
MANISH Amit

(iv)
Manish

[7]
32 ½ mark for 4
import csv accepting
def createcsv(): data
f=open("[Link]","w", newline="")
correctly
w=[Link](f)
[Link]([1,'Anil',40,34,90,""])
½ mark for
[Link]([2,'Sohan',78,34,90,""])
[Link]([3,'Kamal',40,45,9,""]) opening and
[Link]() closing file

import csv ½ mark for


def copycsv(): writing
f=open("[Link]","r") headings
f1=open("[Link]","w",newline="")
w1=[Link](f1) ½ mark for
r=[Link](f)
for x in r: writing row
x[5]=int(x[2])+int(x[3])+int(x[4])
[Link](x) ½ mark for
[Link]() opening and
[Link]() closing file

½ mark for
reader object

½ mark for
print heading

½ mark for
printing data

SECTION E
33 (i) M/s Computer Solutions should install its server in finance block as it 1 Mark of 1*5=5
each correct
is having maximum number of computers. answer
(ii) Any suitable layout

(iii) Satellite Link.

(iv) Switch.

(v) LAN

[8]
34 (i) 1 mark for 2+3=5
rb+ Opens a file for both reading and writing in binary format. (+) the file each correct
pointer will be at the beginning of the file.
difference
wb+ Opens a file for both reading and writing in binary format. Overwrites ½ mark for
the existing file If the file exists. If the file does not exist, creates a new
file for reading or writing. correctly
opening and
(ii) def Readfile(): closing files
s=open( “[Link]” , “rb+”)
try:
while True:
r=[Link](s)
if r[2]>=20000 and r[2]<=30000:
print(r)
except: ½ mark for
print(“end of file”) correct loop

OR ½ mark for
correct split

1 mark for
correctly
(i) reading /
In pickle module, dump () method is used to convert (pickling) writing data
Python objects for writing data in a binary file
½ mark for
Whereas the load () function is used to read data from a binary printing
file or file object.
data
(ii)
import pickle as p
L=[]
with open(‘[Link]’,’rb’) as f:
L=[Link](f)
for r in L:
if r[2]>5000:
print(“name=”,r[0])
print(“designation=”,r[1])
print(“salary=”,r[2])

Note: Any other correct logic may be marked

[9]
35 (i) A table can only have one primary key, but it can have multiple ½ mark for 1+4=5
candidate key in a database. (any suitable example) correct
definition

(ii) ½ mark for


import [Link] correct
mydb=[Link](host="localhost",user="root",passwd="admin",dat example
abase="SCHOOL")
mycursor=[Link]()
while 1:
ch=int(input("enter -1 to exit / any other no to insert record into student table")) ½ mark for
if ch==-1: importing
break
correct
eno=int(input("Enter Employee no"))
ename=input("Enter Employee Name") module
edept=input("Enter dept name")
sal=int(input("Enter salary"))
[Link]("insert into EMP values ('"+str(eno)+"','"+ ename+"','" +edept +
"','"+str(sal)+"')") 1 mark for
[Link]() correct
for x in mycursor:
print(x) connect()

OR ½ mark for
correctly
(i)
accepting the
Degree: The total number of attributes which in the relation is called the input
degree of the relation.
Cardinality: Total number of rows present in the Table. 1 ½ mark for
(any suitable example) correctly
displaying
(ii)
data

import [Link]
mydb=[Link](host="localhost",user="root",passwd="admin",databas
e="SCHOOL")
mycursor=[Link]()
[Link]("alter table emp add (bonus int(3))")
[Link]("desc emp")

for x in mycursor:
print(x)

Note: Any other correct logic may be marked

[10]
(SET 1)
Computer Science (083)
PRE BOARD EXAMINATION 2023-24

Maximum Marks: 70 Time Allowed: 3 hours


General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in
Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1. State True or False 1
“Dictionaries in python are mutable.”
2. Which of the following is an invalid identifier 1
a)myname b)p9tv c)def d)_new

3. Which one of the following is the function to get list of keys from a dictionary 1
dict in python?

a. [Link]()
b. [Link]()
c. [Link]()
d. None Of These

4. Consider the given expression: 1


True OR NOT False AND True
Which of the following will be correct output if the given expression is
evaluated?

(a) True
(b) False
(c) NONE
(d) NULL

5. Select the correct output of the code: 1


Str=”I will Succeed”

1
lis=[Link](“ “)
print(lis[-1])

(a) I
(b) will
(c) Succeed
(d) ”I will Succeed”

6. Which of the following methods will give the current position of the file 1
pointer?

(a)seek() (b)tell() (c)getloc() (d) None of the above

7. Fill in the blank: 1

Command is used to change the structure of the table in SQL.

(a)update (b)remove (c)alter (d)drop

8. Which of the following commands will delete the row of the table from 1
MYSQL database?
(a) DELETE
(b) DROPTABLE
(c) REMOVETABLE
(d) ALTERTABLE

9. Which of the following statement(s) would give an error after 1


executing the following code?

T=(8,9,7,6) # Statement 1
print(T) # Statement2
T=(7,9,7,6) # Statement3
T[1]=8 # Statement4
T=T+(1,2,3) # Statement5

(a) Statement3
(b) Statement4
(c) Statement5
(d) Statement 4 and5

10. Fill in the blank: 1

is an attribute or set of attributes eligible to become primary


key.
(a) PrimaryKey
(b) ForeignKey
(c) CandidateKey

2
(d) Alternate Key

11. The default mode of opening a file in pyhton 1


(a) append
(b) read
(c) write
(d) both b and c
12. Which of the following can be used as command to get the structure of a table in 1
mysql

(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
13. Fill in the blank: 1
Is the protocol used for server to server mail transfer?

(a)VoIP (b)SMTP (c)PPP (d)HTTP

14. What will the following expression be evaluated to in Python? 1


print(2**3**2//8)

(a)64.0 (b)64 (c)8 (d)None Of These

15. Which clause is used to apply conditions with GROUP BY 1


(a) WHERE
(b) HAVING
(c) LIKE
(d) None Of These

16. Which function is used to establish connection between python and SQL 1
database?

(a) connection
(b) connect
(c) getconnection
(d) getconnect

Q17 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

3
(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):-Functions in a program increases the modularity and readability 1
of the program
Reasoning (R):-Usage of Functions increases the execution speed of the
program

18. Assertion (A): If a file is opened in binary mode its contents are viewed as a 1
sequence of bytes.
Reason (R): A text file also can be opened in binary mode

SECTION B
19. Rahul has written a code to input a number and return its reverse. His code is 2
having errors. Rewrite the correct code and underline the corrections made.

def reverse()
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev

20. What do you mean by protocol? Give two examples 2

OR

What is a MODEM? Explain its use?

21. (a) Given is a Python string declaration: 1


Mystr=”I will win”

Write the output of: print(Mystr[2:6])

(b) Write the output of the code given below:


dictcount={“age1”:26,”age2”:32,”age3”:40} 1
sum=0
for key in dictcount:
sum=sum+dictcount[key]
print(sum)

22. Explain the use of ‘Primary Key’ in a Relational Database Management 2


System. Give example to support your answer.

23. (a) Write the full forms of the following: 2


(i) FTP (ii)TCP

4
(b) What is the use of POP3?

24. Predict the output of the Python code given below: 2


def product(L1,L2):
p=0
for i in L1:
for j in L2:
p=p+i*j
return p
LIST=[1,2,3,4,5,6]
l1=[]
l2=[]
for i in LIST:
if(i%2==0):
[Link](i)
else:
[Link](i)
print(product(l1,l2))

OR

Predict the output of the Python code given below:


tuple1 = (33, 24, 44, 42, 54 ,65)
list1 =list(tuple1)
new_list = []
for i in list1:
if i>40:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)

25. Explain the use of DISTINCT keyword in python with appropriate example 2
OR

What is called DDL commands in mysql?Give examples?

SECTION C

26. a)Consider the following tables -Product and Supplier: 1+2


Table:Product
Pid pname sid
P1 pen S1
P2 ball S2
P3 pencil S3
Table:Supplier
Sid sname
S1 Anmol
S2 Aradhya
S3 Sunil
S4 Vishal
5
What will be the output of the following statement?
SELECT * FROM product NATURAL JOIN SUPPLIER;
b)Write the outputof the queries (i) to (iv) based on the table EMPLOYEE given
below
Empid Empname Salary Deptid
E1 Prabhath 12000 D1
E2 Nikhil 14000 D1
E3 Devansh 10000 D2
E4 Debraj 15000 D3
E5 Aron 18000 D1

(i)SELECT DISTINCT deptid from Employee;


(ii)SELECT deptid,count(*),min(salary) from employee GROUP BY deptid
HAVING count(deptid)>2;
(iii)SELECT empname FROM employee WHERE salary>14000 ORDER BY
empname;
(iv)SELECT SUM(SALARY) FROM Employee WHERE SALARY
BETWEEN 15000 AND 18000;

27. Write a method COUNTLINES() in python to read lines from text file 3
[Link] and display the count of lines which are starting with letter T
Example:if the file content is as follows:
Trees are the precious
We should protect trees
This way we can serve nature

The COUNTLINES() function should display output as:


The number of lines starting with letter T :2

OR

Write a function COUNTOWEL() IN PYTHON which should read each


character of a text file [Link] and display the count of vowels

Example:

If the file content is as follows:


Exam is going on well

The COUNTOWEL() function should display the output as:


7

28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:

6
BOOK

Book_id Book_name Price Qty Author_id


1001 My first C++ 323 12 204
1002 SQL basics 462 6 202
1003 Thunderbolts 248 10 203
1004 The tears 518 3 204

AUTHOR

Author_id Author_name Country


201 William Hopkins Australia
202 Anita India
203 Anna Roberts USA
204 Brain Brooke Italy

(i) SELECT Author_id, avg(price) from BOOK GROUP BY


Author_id;
ii) SELECT MAX(price),MIN(price) from BOOK;
ii) SELECT Book_name,Author_name,country from BOOK B,
AUTHOR A WHERE B.Author_id = A.Author_id AND price>300;
iv) SELECT Author_name from AUTHOR WHERE Author_name LIKE
“A%”;
29. Write a function EVEN_LIST(L), where L is the list of elements passed 3
as argument to the function. The function returns another list named ‘even list’
that stores even numbers in the list.
For example:

If L contains [1,2,3,4,5,6,7,8]

The even list will have - [2,4,6,8]

30. A list contains following record of a student: 3


[student_name, age, hostel]

Write the following user defined functions to perform given operations on the
stack named ‘stud_details’:
(i) Push_element() - To Push an object containing name and age of
students who live in hostel “Ganga” to the stack
(ii) Pop_element() - To Pop the objects from the stack and display
them. Also, display “Stack Empty” when there are no elements in the
stack.
For example:
If the lists of customer details are:

[“Barsat”,17,”Ganga”]
[“Ruben”, 16,”Kaveri”]
[“Rupesh”,19,”Yamuna”]
The stack should contain
7
[“Barsat”,17,”Ganga”]
The output should be:
[“Barsat”,17,”Ganga”]
Stack Empty

OR

A list named as Record contains following format of for students:


[student_name, class, city].
Write the following user defined functions to perform given operations on the
stack named ‘Record’:
(i) Push_record(Record) – To pass the list Record = [ ['Rahul', 12,'Delhi'],
[‘Kohli',11,'Mumbai'], ['Rohit',12,'Delhi'] ] and then Push an object containing
Student name, Class and City of student belongs to ‘Delhi’ to the stack Record
and display and return the contents of stack
(ii) Pop_record(Record) – To pass following Record [[“Rohit”,”12”,”Delhi”]
[“Rahul”, 12,”Delhi”] ] and then to Pop all the objects from the stack and at last
display “Stack Empty” when there is no student record in the stack. Thus the
output should be: -
[“Rohit”,”12”,”Delhi”]
[“Rahul”, 12,”Delhi”]
Stack Empty

SECTION D

31
Hi-tech Training center, a Mumbai based organization is planning to
expand their training institute to Chennai. At Chennai compound,
they are planning to have three different blocks for admin, training
and accounts related activities. As a network consultant you have to
suggest some network related solutions to the organization

Shortest distance between the blocks Number of computers installed


are given below: in each block are as follows:
Admin  Accounts 300 meters Training 150
Block
Accounts 150 meters Accounts 30
training block
8
I Admin  Training 200 meters Admin Block 20
Mumbai  1300 KM
Chennai office

i) Suggest the most suitable block to house the server at Chennai block for 1
best and effective connectivity.
Suggest the type of network for the new training institute and draw
ii) 1
the cable layout for the Chennai office
Suggest a hardware/software that would provide the data security for entire network of Chennai
1
iii) region.
Suggest a device that shall be needed to provide wireless internet access to all smart
1
iv) phones/laptop users in Chennai office.
Suggest the protocol used for video conferencing between Chennai
1
v) office and Mumbai office

32. (a) Write the output of the code given below: 2+3
val=4
def findval(m,n=10):
val=0
val=val+m*n
a=10
b=20
findval(a,b)
print(val,end="-")
findval(a)
print(val,end="-")

(b) The code given below inserts the following record in the table
Employee:

Empid – integer Name – string salary-float


Note the following to establish connectivity
between Python and MYSQL:
Username is root
Password is tiger
The table exists in a MYSQL database named Empolyee.
The details (Empid, Name, salary) 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 Employee.
Statement 3- to add the record permanently in
the database
9
import [Link]
from [Link] import Error
connection = [Link](host='localhost',
database='Employee',
user='root',
password='tiger')

cursor=_______________________#STATEMENT1
empid=int(input("enter Empid"))
name=input("enter name")
salary=float(input("ENTER SALARY"))
result = __________________________#STATEMENT2
___________________________________#STATEMENT3

OR

(a) Predict the output of the code givenbelow:


s="PREboardCS*2022!"
j=2
for i in [Link]('*'):
k=i[:j]
if [Link]():
j=j+1
elif [Link]():
j=j+2
else:
j=j+3
print(s [ j : : j ] )

(b) The code given below reads the following record from the table
named Employee and displays only those records who have Salary
greater than 25000:

Note the following to establish connectivity between Python and


MYSQL:
 Username is root
 Password is tiger
 The table exists in a MYSQL database named Employee.

Write the following missing statements to complete the code: Statement 1 – to


form the cursor object
Statement 2 – to execute the query that extracts records of those
Employees who have salary greater than 25000.
Statement 3- to read the complete result of the query (records whose
salary greater than 25000) into the object named records, from the table
Employee in the database.

import [Link]
10
connection = [Link](host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=________________________#STATEMENT1
_________________________________________#STATEMENT2
records = _____________________________#STATEMENT3
for row in records:
print("Empid",row[0],end=" ")
print("name",row[1],end=" ")
print("salary",row[2],end=" ")
print()

33. What is a csv file? 5


Write a Program in Python that defines and calls the following user defined
functions:

(i) INSERT() – To accept and add data of a student to a CSV file


‘[Link]’. Each record consists of a list with field elements as sid,
name and marksto store student id, name and marks respectively.
(i) COUNTSTUDENTS() – To count the number of records present in
theCSV file named‘[Link]’.

OR

What is the purpose of delimiter?


Write a Program in Python that defines and calls the following user defined
functions:

(i) add() – To accept and add data of a product to a CSV file


‘[Link]’. Each record consists of a list with elements as
pid, pnameand priceto storeproduct id, product name and
pricerespectively.
(i) search()- To display the records of the products whose price is
more than5000.

SECTION E

34. Rahul created following table TRAVEL to store the travel details 1+1+2

11
Based on the data given above answer the following questions:

(i) Identify the most appropriate column, which can be considered as


Primary key.
(ii) If 3 columns are added and 1rows are deleted from the table TRAVEL,
what will be the new degree and cardinality of the above table?
(iii) Write the statements to:
a. Insert the following record into the table
110 BIMAL 28-11-2022 200 VOLVO BUS 40

b. Increase KM travelled by 10 if the VTYPE is VOLVO.


OR (Option for part iii only)

(iii) Write the statements to:


a. Delete the record of travel of traveler NANDA.
b. Add a column MILEAGE in the table with data type as integer
35. Biplab is a Python programmer. He has written a code and created a binary file
[Link] which has structure (admission_number, Name, Percentage).
He has written an incomplete function countrec() in Python that would read
contents of the file “[Link]” and display the details of those students
whose percentage is above 75. Also display number of students scoring above
75%.As a Python expert, help him to complete the following code based on the
requirement given above:
import __________#statement1
def countrec():
_____________________#Statement2
records=_______________#Statement3
count=0
for record in records:
if(_______________):#Statement4
count=count+1
12
print("ID",record[0])
print("NAME",record[1])
print("PERCENTAGE",record[2])
print("No of students with perentage above 75",count)

(i) Which module should be imported in the program? (Statement1) 1


(ii) Write the correct statement required to open a file named
[Link] in binary mode (Statement2) 1
(iii) Which statement should Biplab fill in Statement 3 to read the
data from the binary file, [Link] in Statement 4 to check the
percentage?
OR 2
Explain various functions used in writing rows in csv file.

13
(SET 1)

Computer Science (083)


PRE BOARD EXAMINATION
MARKING SCHEME
Maximum Marks:70 Time Allowed: 3 hours
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given
in Q34 against part only.
8. All programming questions are to be answered using Python Language only.

SECTION
A
1. State True or False 1
“Dictionaries in python are mutable.”
Ans:True
2. Which of the following is an invalid identifier 1
a)myname b)p9tv c)def d)_new

Ans:c def
3. Which one of the following is the function to get list of keys from a dictionary 1
dict in python?

a. [Link]()
b. [Link]()
c. [Link]()
d. None Of These

Ans: c [Link]()
4. Consider the given expression: 1
True OR NOT False AND True
Which of the following will be correct output if the given expression is
evaluated?

(a) True
(b) False
(c) NONE
(d) NULL

Ans:A True
5. Select the correct output of the code: 1
Str=”I will Succeed”
1
lis=[Link](““)
print(lis[-1])

(a) I
(b) will
(c) Succeed
(d) ”I will Succeed”

ANS:c Succeed
6. Which of the following methods will give the current position of the file 1
pointer?

(a)seek() (b)tell() (c)getloc() (d) None of the above

ANS:b tell()
7. Fill in the blank: 1

command is used to change the structure of the table in SQL.

(a)update (b)remove (c)alter (d)drop

ANS: c alter
8. Which of the following commands will delete the contents of the table from 1
MYSQL database?
(a) DELETE
(b) DROPTABLE
(c) REMOVETABLE
(d) ALTERTABLE

ANS:a DELETE
9. Which of the following statement(s) would give an error after 1
executing the following code?

T=(8,9,7,6) # Statement 1
print(T) # Statement2
T=(7,9,7,6) # Statement3
T[1]=8 # Statement4
T=T+(1,2,3) # Statement5

(a) Statement3
(b) Statement4
(c) Statement5
(d) Statement 4 and5

ANS:b statement 4

2
10. Fill in the blank: 1

is an attribute or set of attributes eligible to become primary


key.
(a) PrimaryKey
(b) ForeignKey
(c) CandidateKey
(d) Alternate Key
ANS:c candidate key
11. The default mode of opening a file in pyhton 1
(a) append
(b) read
(c) write
(d) both b and c

ANS:b read
12. Which of the following can be used as command to get the structure of a table in 1
mySQL

(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
ANS:a DESCRIBE
13. Fill in the blank: 1
Is the protocol used for server to server mail transfer?

(a)VoIP (b)SMTP (c)PPP (d)HTTP

ANS:b SMTP

14. What will the following expression be evaluated to in Python? 1


print(2**3**2//8)

(a)64.0 (b)64 (c)8 (d)None Of These

ANS: b 64

15. Which clause is used to apply conditions with GROUP BY 1


(a) WHERE
(b) HAVING
(c) LIKE
(d) None Of These
ANS:b HAVING

3
16. Which function is used to establish connection between python and SQL 1
database?

(a) connection
(b) connect
(c) getconnection
(d) getconnect

ANS:b connect

Q17 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):-Functions in a program increases the modularity and readability 1
of the program
Reasoning (R):-Usage of Functions increases the execution speed of the
program

ANS: c A is True but R is False

18. Assertion (A): If a file is opened in binary mode its contents are viewed as a 1
sequence of bytes.
Reason (R): A text file also can be opened in binary mode

ANS: b Both A and R are true and R is not the correct explanation for A

SECTION
B
19. Rahul has written a code to input a number and return its reverse. His code is 2
having errors. Rewrite the correct code and underline the corrections made.

def reverse()
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev

ANS:
def reverse():
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev

½ marks for each correction


4
20. What do you mean by protocol? Give two examples 2
ANS:1 mark for the definition and 1 mark for the example

OR

What is a MODEM? Explain its use?

ANS:MODULATOR DEMODULATOR
2marks for correct explanation.

21. (a) Given is a Python stringdeclaration: 1


Mystr=”I will win”

Write the output of: print(Mystr[2:6])


ANS:will 1

(b) Write the output of the code givenbelow:


dictcount={“age1”:26,”age2”:32,”age3”:40}
sum=0
for key in dictcount:
sum=sum+dictcount[key]
print(sum)
ANS:98

22. Explain the use of ‘Primary Key’ in a Relational Database Management 2


System. Give example to support your answer.
1 mark for example and 1 mark for explanation

23. (a) Write the full forms of thefollowing: 2


(i) FTP (ii)TCP

(b) What is the use of POP3?

ANS:FTP-FILE TRANSFER PROTOCOL ½ MARKS


TCP-TRANSMISSION CONTROL PROTOCOL ½ MARKS
1 MARK FOR THE EXPLANATION OF POP3
24. Predict the output of the Python code given below: 2
def product(L1,L2):
p=0
for i in L1:
for j in L2:
p=p+i*j
return p
LIST=[1,2,3,4,5,6]
l1=[]
l2=[]
for i in LIST:
if(i%2==0):
[Link](i)
else:
[Link](i)
print(product(l1,l2))
5
ANS:108

OR

Predict the output of the Python code given below:


tuple1 = (33, 24, 44, 42, 54 ,65)
list1 =list(tuple1)
new_list = []
for i in list1:
if i>40:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
ANS: (44, 42, 54, 65)

25. Explain the use of DISTINCT keyword in python with appropriate example 2
ANS:DISTINCT keyword discards duplicate vales
1 mark for explanation and 1 mark for example

OR

What is called DDL commands in mySQL?Give examples?


DDL-DATA DEFENITION LANGUAGE
EXAMPLE:CREATE ,DROP,ALTER

SECTION C

26. a)Consider the following tables -Product and Supplier: 1+2


Table:Product
Pid pname sid
P1 pen S1
P2 ball S2
P3 pencil S3
Table:Supplier
Sid sname
S1 Anmol
S2 Aradhya
S3 Sunil
S4 Vishal

What will be the output of the following statement?


SELECT * FROM product NATURAL JOIN SUPPLIER;
ANS:
Pid pname sid Sname
P1 Pen S1 Anmol
P2 Ball S2 Aradhya
P3 Pencil S3 Sunil

b)Write the outputof the queries (i) to (iv) based on the table EMPLOYEE given
below
Empid Empname Salary Deptid
6
E1 Prabhath 12000 D1
E2 Nikhil 14000 D1
E3 Devansh 10000 D2
E4 Debraj 15000 D3
E5 Aron 18000 D1

(i)SELECT DISTINCT deptid from Employee;


(ii)SELECT deptid,count(*),min(salary) from employee GROUP BY deptid
HAVING count(deptid)>2;
(iii)SELECT empname FROM employee WHERE salary>14000 ORDER BY
empname;
(iv)SELECT SUM(SALARY) FROM Employee WHERE SALARY
BETWEEN 15000 AND 18000;
ANS:(i)
Deptid
D1
D2
D3
1/2 marks
(ii)
Deptid count(*) min(salary)
D1 3 12000
1/2 marks

(iii)
Empname
Aron
Debraj
1/2 marks
(iv)
Sum(Salary)
33000
1/2 marks

27. Write a method COUNTLINES() in python to read lines from text file 3
[Link] and display the count of lines which are starting with letter T
Example:if the file content is as follows:
Trees are the precious
We should protect trees
This way we can serve nature

The COUNTLINES() function should display output as:


The number of lines starting with letter T :2

ANS:
def COUNTLINES():
fp=open("[Link]","r")
7
count=0
lines=[Link]()
for line in lines:
if(line[0]=="T"):
count=count+1
print("The number of lines starting with letter T :",count)

OR

Write a function COUNTOWEL() IN PYTHON which should read each


character of a text file [Link] and display the count of vowels

Example:

If the file content is as follows:


Exam is going on well

The COUNTOWEL() function should display the output as:


7
ANS:
def COUNTVOWELS():
fp=open("[Link]","r")
count=0
characters=[Link]()
characters=[Link]()
for character in characters:
if(chatacter in ['a','e','i','o','u']):
count=count+1
print(count)

28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
BOOK
Book_id Book_name Price Qty Author_id
1001 My first C++ 323 12 204
1002 SQL basics 462 6 202
1003 Thunderbolts 248 10 203
1004 The tears 518 3 204

AUTHOR
Author_id Author_name Country
201 William Hopkins Australia
202 Anita India
203 Anna Roberts USA
204 Brain&Brooke Italy

(i) SELECT Author_id, avg(price) FROMBOOK GROUP


BYAuthor_id;
8
ii) SELECT MAX(price),MIN(price) FROM BOOK;
ii) SELECTBook_name,Author_name,countryFROM BOOK B,
AUTHOR A WHERE B.Author_id = A.Author_idANDprice>300;
iv) SELECT Author_name FROM AUTHOR WHERE Author_nameLIKE
“A%”;
ANS:
(i)
Author_id Avg(price)
204 420.5
202 462
203 248
(ii)
MAX(price) MIN(price)
518 248
(iii)
Book_name Author_nam Country
e
My First Brain&Broo Italy
C++ ke
SQL Basics Anita India
The Tears Brain&Broo Italy
ke
(iv)
Author_name
Anita
Anna Roberts
29. Write a function EVEN_LIST(L), where L is the list of elements passed 3
as argument to the function. The function returns another list named ‘evenlist’
that stores even numbers in the list.

For example:

If L contains [1,2,3,4,5,6,7,8]

The evenlist will have - [2,4,6,8]


ANS:
def EVEN_LIST(L):
evenlist=[]
for i in L:
if(i%2==0):
[Link](i)
9
return evenlist

30. A list contains following record of a student: 3


[student_name, age, hostel]

Write the following user defined functions to perform given operations on the
stack named ‘stud_details’:
(i) Push_element() - To Push an object containing nameand
age of students who live in hostel “Ganga” to the stack
(ii) Pop_element() - To Pop the objects from the stack and display
them. Also, display “Stack Empty” when there are no elements in
thestack.
For example:
If the lists of customer detailsare:

[“Barsat”,17,”Ganga”]
[“Ruben”, 16,”Kaveri”]
[“Rupesh”,19,”Yamuna”]
The stack should contain
[“Barsat”,17,”Ganga”]
The output should be:
[“Barsat”,17,”Ganga”]
Stack Empty
ANS:
stud_details=[]
def push_element(lis):
if(lis[2]=="Ganga"):
stud_details.append([lis[0],lis[1]])
def pop_element():
while(len(stud_details)>0):
print(stud_details.pop())
print("Stack Empty")

OR

def Push_record(): # (1½ mark for correct push element)


for i in List:
if i[2]=="Delhi":
[Link](i)
print(Record)
def Pop_record(): # (1½ mark for correct push element)
while True:
if len(Record)==0:
print('Empty Stack')
break
10
else:
print([Link]())
Push(Dict_Product)
(1 mark for correct function header
1 mark for correct loop
½ mark for correct If statement
½ mark for correct display of count)
SECTION D

31
HiTech Training center, a Mumbai based organization is planning to
expand their training institute to Chennai. At Chennai compound,
they are planning to have three different blocks for admin, training
and accounts related activities. As a network consultant you have to
suggest some network related solutions to the organization

Shortest distance between the blocks Number of computers installed


are given below: in each block are as follows:
Admin  Accounts 300 meters Training 150
Block
Accounts 150 meters Accounts 30
training block
I Admin  Training 200 meters Admin Block 20
Mumbai  1300 KM
Chennai office
i) 1

Suggest the most suitable block to house the server at Chennai block for 1
ii) best and effective connectivity.
Suggest the type of network for the new training institute and draw 1
iii) the cable layout for the Chennai office
Suggest a hardware/software that would provide the data security 1
iv) for entire network of Chennai region.
Suggest a device that shall be needed to provide wireless 1
v) internet access to all smart phones/laptop users in Chennai office.
Suggest the protocol used for video conferencing between Chennai
11
office and Mumbai office
ANS:
i)Training Block
ii)LAN
iii)FIREWALL
iv)ACCESS POINT
v)H.323 or SIP

32. (a) Write the output of the code given below: 2+3
val=4
def findval(m,n=10):
val=0
val=val+m*n
a=10
b=20
findval(a,b)
print(val,end="-")
findval(a)
print(val,end="-")

ANS:4-4-

(b) The code given below inserts the following record in the table
Employee:

Empid – integer Name – string salary-float


Note the following to establish connectivity
between Python and MYSQL:
Username is root
Password is tiger
The table exists in a MYSQL database named Empolyee.
The details (Empid, Name, salary) 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 Employee.
Statement 3- to add the record permanently in
the database

import [Link]
from [Link] import Error
connection = [Link](host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=_______________________#STATEMENT1
empid=int(input("enter Empid")) 12
name=input("enter name")
salary=float(input("ENTER SALARY"))
result = __________________________#STATEMENT2
___________________________________#STATEMENT3
ANS:
STATEMENT1:[Link]()
STATEMENT2:[Link]("insert into employee
values(%s,%s,%s)",(empid,name,salary))

STATEMENT3:[Link]()

OR

(a) Predict the output of the code givenbelow:


s="PREboardCS*2022!"
j=2
for i in [Link]('*'):
k=i[:j]
if [Link]():
j=j+1
elif [Link]():
j=j+2
else:
j=j+3
print(s [ j : : j ] )
ANS:
brS0!

(b) The code given below reads the following record from thetable
named Employeeand displays only those records who have Salary
greater than 25000:

Note the following to establish connectivity between Python and


MYSQL:
 Username isroot
 Password istiger
 The table exists in a MYSQL database namedEmployee.

Write the following missing statements to complete the code: Statement 1 – to


form the cursor object
Statement 2 – to execute the query that extracts records of those
Employees who have salary greater than 25000.
Statement 3- to read the complete result of the query (records whose
salary greater than 25000) into the object named records, from the table
Employeein the database.

import [Link]
connection = [Link](host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=________________________#STATEMENT1
_________________________________________#STATEMENT2
13
records = _____________________________#STATEMENT3
for row in records:
print("Empid",row[0],end=" ")
print("name",row[1],end=" ")
print("salary",row[2],end=" ")
print()
ANS:
Statement 1 :[Link]()
Statement 2 :[Link]("select * from employee where salary>25000")
Statement 3:[Link]()
33. What is a csv file? 5
Write a Program in Python that defines and calls the following user defined
functions:

(i) INSERT() – To accept and add data of a student to a CSV file


‘[Link]’. Each record consists of a list with field elements as sid,
name and marksto store student id, name and marks respectively.
(i) COUNTSTUDENTS() – To count the number of records present in
theCSV file named‘[Link]’.
ANS:
import csv
def INSERT():
studlist=[]
while(choice=="y"):
sid=int(input("Enter Student id"))
name=input("Enter name")
marks=input("Enter Marks")
choice=input("Enter y to continue or press any to exit")
student=[sid,name,marks]
[Link](student)
file=open("[Link]","w")
writer=[Link](file)
[Link](studlist)

def COUNTSTUDENTS():
file=open("[Link]","r")
reader=[Link](file)
print("No of students",len(reader))

OR

What is the purpose of delimiter?


Write a Program in Python that defines and calls the following user defined
functions:

(i) add() – To accept and add data of a product to a CSV file


‘[Link]’. Each record consists of a list with elements as
pid, pnameand priceto storeproduct id, product name and
pricerespectively.
(i) search()- To display the records of the products whose price is
more than5000.
14
ANS:
import csv
def add():
prodist=[]
while(choice=="y"):
pid=int(input("Enter product id"))
pname=input("Enter name")
price=input("Enter price")
choice=input("Enter y to continue or press any to exit")
product=[pid,pname,price]
[Link](product)
file=open("[Link]","w")
writer=[Link](file)
[Link](prodlist)
def search():
file=open("[Link]","r")
reader=[Link](file)
for record in reader:
if(record[2]>5000):
print("Product id",record[0])
print("Product name",record[1])
print("Product price",record[2])
1 mark for correct explanation of question
½ marks for correctly opening the file
½ marks for creating reader and writer objects
Full marks for correct code
SECTION E

34. Rahul created following table TRAVEL to store the travel details 1+1+2

Based on the data given above answer the following questions:

(i) Identify the most appropriate column, which can be considered as


Primary key.
(ii) If 3 columns are added and 1rows are deleted from the table TRAVEL,
15
what will be the new degree and cardinality of the above table?

(iii) Write the statements to:


(a) Insert the following record into the table
110 BIMAL 28-11-2022 20 VOLVO BUS 40

(b) Increase KM travelled by 10 if the VTYPE is VOLVO.

ANS:
a)(i)TNO (ii)degree-9 cardinality-6
iii)[Link] INTO TRAVEL VALUES(110,’BIMAL’,’28-11-
2022’,200,’VOLVOBUS’,40)
[Link] TRAVEL SET KM=KM+10 WHERE VTYPE=’VOLVO
BUS’
OR (Option for part iii only)

(iii) Write the statements to:


a. Delete the record of travel of traveler NANDA.
b. Add a column MILEAGE in the table with data type as
integer
ANS:
a)DELETE FROM TRAVEL WHERE TNAME=’NANDA’
b)ALTER TABLE TRAVEL ADD(MILEAGE int)
35. Biplab is a Python programmer. He has written a code and created a binary file
[Link] which has structure (admission_number, Name, Percentage).
He has written an incomplete function countrec() in Python that would read
contents of the file “[Link]” and display the details of those students
whose percentage is above 75. Also display number of students scoring above
75%.As a Python expert, help him to complete the following code based on the
requirement given above:
import __________#statement1
def countrec():
_____________________#Statement2
records=_______________#Statement3
count=0
for record in records:
if(_______________):#Statement4
count=count+1
print("ID",record[0])
print("NAME",record[1])
print("PERCENTAGE",record[2])
print("No of students with perentage above 75",count)

(i) Which module should be imported in the program? (Statement1)


(ii) Write the correct statement required to open a file named
[Link]. in binary mode (Statement2)
16 1
(iii) Which statement should Biplab fill in Statement 3 to readthe
data from the binary file, [Link] in Statement 4 to check the 1
percentage?
ANS
(i) pickle
2
(ii)fp=open("[Link]","rb")
(iii)records=[Link](fp)
if(record[2]>75)

17
18
19
12COM03QP
KENDRIYA VIDYALAYA SANGATHAN , CHENNAI REGION
PRE-BOARD-I EXAMINATION 2023-2024
CLASS XII-COMPUTER SCIENCE (083)
TIME: 03 HOURS M.M.: 70
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 02 Long Answer type questions carrying 04 marks each.
7. Section E has 03 questions carrying 05 marks each.
8. All programming questions are to be answered using Python Language only.
SECTION A
1. Assign a tuple containing an Integer? (1)

2. Which of the following data type in Python supports concatenation? (1)


a) int b) float c) bool d) str
3. What will be output of the following code: (1)
d1={1:2,3:4,5:6}
d2=[Link]()
print(d2)
a){1:2} b){5:6} c)(1,2) d)(5,6)

4. The correct output of the given expression is: (1)


True and not False or False
(a)False (b)True(c)None (d) Null

5. Fill in the blank: (1)


Command is used to add a new column in a table in SQL.
a)update b)remove c)alter d)drop
6. Consider the Python statement: [Link](10, 1) (1)
Choose the correct statement from the following:

(a) File pointer will move10 byte in forward direction from beginning of the file
(b) File pointer will move 10 byte in forwarddirection from end of the file
(c) File pointer will move 10 byte inforwarddirection from current location
(d) File pointer will move 10 byte in backward direction from current location
7. Choose correct SQL query which is expected to delete all rows of a table emp without (1)
deleting its structure.
a) DELETE TABLE;
b) DROP TABLE emp;
c) REMOVE TABL emp;
d) DELETE FROM emp;
8. Which of the following is NOT a DML Command? (1)
(a)Insert (b)Update (c)Drop (d)Delete
9. Select the correct outpu to the code: (1)
a="Year2022atallthe best"
a=[Link]('a')
b=a[0]+"-"+a[1]+"-"+a[3]
print (b)

a) Year–0-atAllthebest
b) Ye-r2022-llthe best
c) Year–022-at Allthebest
d) Year–0-atallthebest

10. Which of the following statement(s) would give an error during execution?
S="Lucknow is the Capital of UP " #Statement1

print(S) #Statement2

S[4]='$’ #Statement3

S="Thankyou" #Statement4

S=S+"Thankyou" #Statement5

(a)Statement3 (b)Statement4 (c)Statement5 (d)Statement4and5

11. Which of the following function returns a list datatype? (1)


a) d=[Link]() b) d=[Link](10) c) d=[Link]() d)d=[Link]()

12. Select the correct statement,with reference to SQL: (1)


a) Aggregate functions ignore NULL
b) Aggregate functions consider NULL as zero or False
c) Aggregate functions treat NULL as a blank string
d) NULL can be written as 'NULL' also.

13. Fill in the blank: (1)


The is a mail protocol used to retrieve mail from a remote server to a local
email client.
(a)VoIP (b) FTP (c)POP3 (d)HTTP
14. What will be the value of y when following expression be evaluated in (1)
Python?
x=10.0
y=(x<100.0) and x>=10
(a)110 (b)False (c)Error (d)True
15. All aggregate functions except ignore null values in their input collection. (1)
(a) Count(attribute)
(b) Count(*)
(c) Avg
(d) Sum
16. Which of the following method is used to create a connection between the MySQL (1)
database and Python?
a) (a) connector ( ) (b) connect ( ) (c) con ( ) (d)cont()
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
c) A is True but R is False
d) A is false but R is True

17. Assertion (A):-The default arguments can be skipped in the function call. (1)
Reason (R):-The function argument will take the default values even if the values are
supplied in the function call

18. Assertion(A):A tuple can be concatenated to a list,but a list cannot be concatenated to a (1)
tuple.
Reason(R):Lists are mutable and tuples are immutable in Python.

SECTION B
19. Ravi has written a function to print Fibonacci series for first 10 element. His code is
having errors. Rewrite the correct code and underline the corrections made. Some initial
(2)
elements of Fibonacci series are:

def fibonacci()
first=0
second=1
print((“first no. is “, first)
print(“[Link],second)
for a in range (1,9):
third=first+second
print(third)
first,second=second,third
fibonacci()

20. What possible outputs (s) are expected to be displayed on screen at the time of (2)
execution of the program from the following code? Also specify the maximum values
that can be assigned to each of the variables FROM and TO.

import random
AR=[20,30,40,50,60,70]
FROM=[Link](1,3)
TO=[Link](2,4)
for K in range(FROM,TO+1):
print(AR[K],end=” #“ )

(i)10#40#70# (ii)30#40#50# (iii)50#60#70# (iv)40#50#70#

21. (a) Given is a Python string declaration: (1)


myexam="RussiaUkrain"
Write the output of :
print(myexam[-[Link]-2])

(b) Write the output of the code given below: (1)


D1={"sname":"Aman","age":26}
D1['age']=27
D1['address']="Delhi"
print([Link]())
22. Explain the use of ‘Foreign Key’ in a Relational [Link] an example to support your (2)
answer.
23. (a) Write the full forms of the following: (1)
(i) POP (ii)HTTPS (1)
(b) Write two points of difference between Circuit Switching and Packet Switching
24. Predict the output of the Python code given below: (2)
value = 50
def display(N):
global value
value = 25
if N%7==0:
value=value+N
else:
value=value-N
print(value, end="#")
display(20)
print(value)

OR
def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('[email protected]')
25. Consider the following two commands with reference to a table, named Students, (2)
having a column named Section:
(a) Select count(Section)from Students;
(b) Select count(*)from Students;
If these two commands are producing different results,
(i) What may be the possible reason?
(ii) Which command,(a)or(b),might be giving higher value?
OR
Name the aggregate functions which work only with numeric data, and those that work
with any type of data.
SECTION C
26. (a)Consider the following tables– EMPLOYEES AND DEPARTMENT (1)

What will be the output of the following statement?


SELECT ENAME, DNAME FROM EMPLOYEES,DEPARTMENT WHERE
[Link]=[Link];
(2)
i) b)Write the output of the queries(i)to(iv) based on the tables given below

i) SELECT ITEM_NAME, MAX(PRICE), COUNT(*) FROM ITEM GROUP BY


ITEM_NAME;
ii) SELECT CNAME,MANUFACTURER FROM ITEM,CUSTOMER WHERE
[Link]=[Link];
iii) SELECT ITEM_NAME, PRICE*100 FROM ITEM WHERE
MANUFACTURER="ABC";
(iv) SELECT DISTINCT CITY FROM CUSTOMER;
27. Write a method SHOWLINES() in Python to readlines from text file
‘[Link]’and display the lines which do not contain 'ke'.

Example: If the file content is as follows:


An apple a day keeps the doctor
away. We all pray for everyone’s
safety.
A marked difference will come in our country.

The SHOWLINES() function should display the output as:


We all pray for everyone’s safety. (3)
OR

Write a function in python to count the number of lines in a text file ‘[Link]’
which are starting with an alphabet ‘W’ or ‘H’.
For example,If thef ile contents are as follows:
Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.
The output of the function should be:
W or w:1 H or
h:2
28. Consider the following tables GAMES. Give outputs for SQL queries (i)to(iv). (2+
1)
Table:GAMES

GCode GameName Number PrizeMoney ScheduleDate


101 CaromBoard 2 5000 23-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 TableTennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 LawnTennis 4 25000 19-Mar-2004
(i) SELECT COUNT(DISTINCT Number) FROM GAMES;
(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM
GAMES;
(iii) SELECT SUM(PrizeMoney) FROM GAMES;
(iv) SELECT * FROM GAMES WHERE PrizeMoney>12000;

(b)Write the command to view all the databases in an RDBMS.


29. Write a function in PythonConvert() to replaces elements having even values (3)
with its half and elements having odd values with twice its value in a list.
eg: if the list contains 3,4,5,16,9 then rearrange the list as 6,2,10,8,18
30. Write a function in Python PUSH_IN(L), where L is a list of numbers. From this (3)
list, push all numbers which are multiple of 3 into a stack which is implemented by
using another list.
OR
Write a function in Python, Push(KItem),where KItem is a dictionary containing
the details of Kitchen items– {Item:price}.

The function should push the names of those items in a stack which have price less
than 100. Also display the average price of elements pushed into the stack.
For example: If the dictionary contains the following data:
{"Spoons":116,"Knife":50,"Plates":180,"Glass":60}

The stack should contain


Glass
Knife
The output should be:
The average price of an item is 55.0
SECTION D
31. Tushar is a Python programmer. He has written a code and created a binary file 4
[Link] with employeeid, ename and salary. The file contains 10 records.

He now has to delete a record based on the employee id entered by the user. For
this purpose, he creates a temporary file, named [Link], to store all the records
other than the record to be deleted. If the employee id is not found, an appropriate
message should to be displayed.

As a Python expert, help him to complete the following code (by completing
statements 1, 2, 3, and 4) based on the requirement given above:

(i) Complete Statement #1 to import the required module.


(ii) Write the correct statement required to open a temporary file named
[Link]. (#Statement 2)
(iii) Which statement should Aman fill in Statement 3 to read the data
from the binary file, [Link]
(iv) What should be written in Statement4 to write there records in the file
[Link]?

import #Statement1
def update_data():
rec={} fin=open("[Link]","rb")
fout=open(" ","") #Statement2
found=False
eid=int(input("Enter employee id:")) while True:
try:
rec= #Statement3
if rec["Employee id"]==eid:
found=Tru
e else:
#Statement 4
except:
break
if found==True:
print("Recorddeleted.")
else:
print("Employee with such id is notfound")
[Link]()
[Link]()
32. A departmental store MyStore is considering to maintain their inventory using 4
SQL to store the data. As a database Administrator, Abhay has decided that:
Name of the database–mystore
Name of the table –STORE
The attributes of STORE are as follows
ItemNo –numeric
ItemName–character of size 20
Scode – numeric
Quantity– numeric
Table : STORE

ItemNo ItemName Scode Quantity


2005 SharpnerClassic 23 60
2003 BallPen0.25 22 50
2002 GelPenPremium 21` 150
2006 GelPenClassic 21 250
2001 EraserSmall 22 110
2004 EraserBig 22 220
2009 BallPen0.5 21 180

(a) Identify the attributes suitable to be declared as primary key


(b) Write the query to add the row with following details
(2010,”Notebook”,23,155)
(c)
i) Abhay wants to remove the table STORE from the database MyStore, Help
Abhay in writingthe command for removing the table STORE from the
database MyStore.

ii) Now Abhay wants to display the structure of the table [Link] of
the attributes and their respective data types that he has used in the table.
Write the query to display the same.
OR
(i) Abhay wants to ADD a new column price with data type as decimal. Write
the query to add the column..
(ii) Now Abhay wants to remove a column price from the table [Link] the
query.

SECTION E
33.
A company ABC Enterprises has four blocks of buildings as shown :
B1 B2

B3 B4.

Distance between various blocks/locations:

B3---- B1:- 50M


B1---- B2:- 60M
B2---- B4:- 25M

B4---- B3:- 170M


B3---- B2:- 125M
B3---- B4:- 90M

Number of computers:

BLOCK B1 --- 150


BLOCK B2 --- 15
BLOCK B3 --- 15 (1)
BLOCK B4 --- 25
(1)
(i) Suggest the most appropriate topology for the connection between the
blocks. (1)
(ii) The company wants internet accessibility in all the blocks. The suitable
and cost effective technology for that would be?
(iii) Which devices will you suggest for connecting all the computers with in (1)
each of the blocks.
(iv) The company is planning to link its head office situated in New Delhi with (1)
the offices in hilly areas. Suggest a way to connect it economically.
(v) Suggest the most appropriate location of the server, to get the best
connectivity for maximum number of computers.
34 (a) Define the term Primary Key with respect to RDBMS. Give one example to (1)
support your answer

(b) The code given below reads records from the table named student and displays only
those records who have marks greater than [Link] structure of a record of table (4)
Student is:
RollNo–integer;Name –string;Clas –integer;Marks– integer

Note the following to establish connectivity between Python and MYSQL:


(i) Username is root
(ii) Password is abc
(iii) The table exists in a MYSQL database named school.
(iv) The details(RollNo,Name,Class and Marks) are to be accepted from the
user.
Write the following missing statements to complete the code:
Statement 1 – to create the cursor object
Statement 2 – to execute the query that extracts records of those students whose
marks are greater than 75.
Statement3-to read the complete result of the query(records whose marks are
greater than 75) into the object named data, from the table student in the
database.

import [Link] as mysql


def sql_data():
con1=[Link](host="localhost",user="root",
password="abc",database="school")
mycursor= #Statement 1
print("Students with marks greater than75are:")
#Statement 2
data= #Statement3
for i in data:
print(i)

35. (i) Write one similarity and one difference between a+ and w+ (2+
(ii) A binary file “[Link]” has structure (EID, Ename, designation,salary) 3)
Write a function Show() in Python that would read the details of employees from the
file “[Link]” and display the details of those employees whose designation is
“Manager”
(OR)
(i) What is the difference between readline() and readlines() ?
(ii) A binary file “[Link]” has structure [BookNo, Book_Name, Author, Price].
Write a function CountRec(Author) in Python which accepts the Author name
as parameter and count and return number of books written by the given Author

****END****
GeneralI s n s t r u c t i o n s

This question paper is divided into 3 Sections - A, B and C.


Section A, consists of 7 questions (1-7). Each question carries 2 marks.

)Section B, consists of 3 questions (8-10). Each question carries


3marks.

oction C, consists of
3 questions (11-13). Each
4 marks. question carries
Tnternal choices have been given for question numbers
7, 8 and 12.

SECTION-A
(Each question carries 2 marks)
1. Stack is linear data structure which follows
à
a
particular order in which
the operations are performed."
2
What is the order in which the operations are performed in a Stackk?

Name the List method/function available in Python which is used to


remove the last element from a list implemented stack.

Also write an example using Python statements for removing the last
element of the list.

2. i) Expand the following: 1

VoIP, PPP

(i) Riya wants to transfer pictures from her mobile phone to her laptop.
She uses Bluetooth technology to connect two devices. Which type of
network (PAN/LANIMAN/WAN) will be formed in this case ?

Page 2
in the context of
. Dfferentiate between the terma Attrilbute and Domain

Relational Data Model.

SQL Database CLUB:


MEMBER in
4 Consider the following SQL table
a

Table : MEMBER

ACTIVITY
M ID NAME

M1001 Amina GYM

M1002 Pratik GYM

SWIMMING
M1003 Simon

M1004 Rakesh GYM

M1005 SWIMMING
Avneet

the connection between


Assume that the required library for establishing
code. Also
Python and MYSQL is already imported in the given Python
connection for table
assume that DB is the name of the database

MEMBER stored in the database CLUB.

Predict the output of the following code

MYCUR [Link] ()

MYCUR. execute ("USE CLUB")

[Link] ("SELECT * FROM MEMBER WHERE ACTIVITY= 'GYM'


)
R=[Link] ()

for i in range (2)

R=MYCUR. fetchone ()

print (R[0], R[11, sep =


"#")

91 Page 3 P.T.O-
of SQL queries
(a) to (d) based on the table
o u t p u t

the below:
given
Write DATA
VACCINATION_ 2
5.
VACCINATI ON DATA
TABLE:

Dosel
Name
Age Dose2 City
VID
2021-12-25
Jenny
27 2022-01-31 Delhi
101

Harjot
55 2021-07-14 | 2021-10-14 Mumbai
102

Srikanth
43 2021-04-18 2021-07-20 Delhi
103

75 2021-07-31 NULL Kolkata


104 Gazala

Shiksha
32 2022-01-01 NULL Mumbai
105

Age FROM VACCINATION DATA


. (a) SELECT
Name,

Dose2. IS NOT
NULL AND Age > 40:
WHERE

COUNT(*)
ERON
VACULNATION DATA GROUP BY Citv:
.(b) SELECT City,

City. FROM VACCINATION DATA;


,(c) SELECT DISTINCT

FROM VACCINATION DATA;


(Dosel), MIN. (DOse2):
(d) SELECT MAX

the following two


6. Write the output of SQL queries (a). and (b) based on

tables DOCTOR and PATIENT belonging to the same database

Table : DOCTOR

DNO DNAME FEES

D1 AMITABH 1500

D2 ANIKET 1000

D3 NIKHIL 1500

D4 ANJANA 1500

91 Page 4
Table : PATIENT
PNO PNAME
ADMDATE DNO

NOOR
P1
2021-12-25 D1

P2 ANNIE
2021-11-20 D2

P3 PRAKASH
2020-12-10 NULL
P4 HARMEET
2019-12-20 D1
(a) SELECT DNAME, PNAME
FROM DOCTOR
NATURAL JOIN PATIENT ;

.
(b) SELECT PNAME,
ADMDATE, FEES
FROM PATIENT P,
DOCTOR D
WHERE D. DNO =
[Link] AND FEES
>100

7. Differentiate between Candidate


Key and Primary Key in the context
Relational Database Model. 2

OR

Consider the following table PLAYER

Table : PLAYER

PNO NAME SCORE

P1 RISHABBH 52

P2 HUSSAIN 45

P3 ARNOLD 23

P4 ARNAV 18

P5 GURSHARAN 42

Page 5 P.T.O.
91
of tthe most
ame of
write.
the
name

appropriate column from the


and
can be Ised as a
)
ldentify

t a b l e
PLAYER
that
Primary key.
Riven

Degree in relational data model.


What is the
D e f i n e
the
m
term

Degree
PLAYER
b) table
given
ofthe

SECTION - B

(Each question carries 3 marks)

Write the definition ot a user defined function PushNV (N) which


S.
accepts a list of strings in the parameter N and pushes all strings

which have no vowels present in it, into a list named NoVowel. 3

Write a program in Python to input 5 words and push them one by

one into a list named All.

The program should then use the function PushNV () to create a

stack of words in the list Novowel so that it stores only those words
which do not have any vowel present in it, from the list All

Thereafter, pop each word from the list NoVowel and display the

popped word. When the stack is empty display the message

"EmptyStack".

For example:
lf the Words accepted and pushed into the list All are

['DRY', 'LIKE' 'RHYTHM', 'WORK', 'GYM'


91 Page 6
Then the stack NovVowel should store

'DRY' 'RHYTHM, 'GYM']

And the output should be


displayed as
GYM RHYTHM DRY
Emptystack
OR
Write the definition of a user defined function Push3 5 (N) whicn

E E s a ist of integers in a parameter N and pushes all those

integers which are divisible by 3 or divisible by 5 from the lhst N

into a list named


Only3_5.
r i t e a program in Python to input 5 integers into a list named NoM.

The program should then use the function Push 3_5() to createthe
stack of the list only3 5. Thereafter pop each integer from the list

only3 5 and display the popped value. When the list is empty,
display the message "StackEupty"
For example
If the integers input into the list NUM are
[10, 6, 14, 18, 301

Then the stack Only3 _5 should store

[10, 6, 18, 30]

And the output should be displayed as

30 186 10 StackEmpty

91 Page 7
P.T.O.
9. )
SOL talble ITEMS contains the following columns
TNO, INAME, QUANTTTY, PRICE, DISCoUNT

Write the SQL command to remove the column DIscoUNT from


the
table.
(i) Categorize the following SQL commands into DDL and DML:
2
CREATE, UPDATE, INSERT, DROP

10. Rohan is learning to work upon Relational


Database Management System
(RDBMS) application. Help him to perform following tasks: 3
(a) To open the database
named "LIBRARY".
b) To display the names of all the tables stored in the opened database.
(c) To display the structure of the table "BOOKS" existing in the already
opened database "LIBRARY".

SECTION - C

(Each question carries 4 marks)


11. Write SQL queries for (a) to (d) based on the tables PASSENGER and
FLIGHT given below: 4

Table : PASSENGER

PNO NAME GENDER FNO

1001 Suresh MALE F101

Anita FEMALEE F104


1002

1003 Harjas MALE F102

FEMALE F103
1004 Nita

Page 8
91
Table : FLIGHT
FNO START END F_DATE FARE

F101 MUMBAI CHENNAI 2021-12-25 4500

F102 MUMBAI BENGALURU 2021-11-20 4000


F103 DELHI CHENNAI 2021-12-10 5500
F104 KOLKATÀA
MUMBAI 2021-12-20 4500
F105 DELHI BENGALURU 2021-01-15 5000

(a) Write a query to change the fare to 6000 of the flight whose FNO is
F104.

(b) Write a query to display the total number of MALE and FEMALE
PASSENGERS.

(c)Write a query to display the NAME, corresponding FARE and F_DATE


of all PASSENGERS who have a flight to START from DELHI.

(d) Write a query to delete the records of flights which end at


Mumbai.

12. ) Differentiate between Bus Topology and Tree


Topology. Also, write
one advantage of each of them. 2

OR

Differentiate between HTML and XML.

(i) What is a web browser ? Write the names of any two commonly used
web browsers.
2

91 Page 9 P.T.O.
Ltd. is planning to
to connect
connect its office in Texas, USA with
Ltd. is planning
Provider

13. Galaxy
The Mumbai
Mumbai. branch has 3 Offices in three blocks
its branch
distance from each other for different operations
located at
ACCOUNTS.
SALES and
ADMIN,

Aa a network consultant, yOu uave O Suggest the best network related

atians for the issues/problems raised in (a) to (d), keeping in mind the

distances between various locations and other given parameters.

Offices in the Mumbai branch:


Layout of the

Admin
Block

Sales
Block

Accounts

Block

between various locations


Shortest distances

300 m
Block
ADMIN Block to SALES
175 m
Block
SALES Block to ACcOUNTS
350 m

ACCOUNTS
Block
ADMIN Block to
14000 km
Head Office
to TEXAS
MUMBAI Branch

Page 10

91
Number of Computers installed at various locations are as follows

ADMIN Block 255


ACCOUNTS Block 75
SALES Block 30
TEXAS Head Office 90
(a) It is observed that there is a huge data loss during the process of

data transfer from one block to another. Suggest the most

be
appropriate networking device out of the following, which needs to
with
placed along the path of the wire connecting one block office
another to refresh the signal and forward it ahead.

) MODEM (i) ETHERNET CARD

(i) REPEATER iv) HUB

b) Which hardware networking device out of the following, will you

suggest to connect all the computers within each block ?

) SWITCH i) MODEM

(ii) REPEATER iv) ROUTER

(c) Which service/protocol out of the following will be most helpful to


conduct live interactions of employees from Mumbai Branch and
their counterparts in Texas ?

() FTP (i) PPP


(ii) SMTP (iv) VolP

(d) Draw the cable layout (block to block) to efficiently connect the three
offices of the Mumbai branch.

91 Page 11
CBSE Additional Practice Question Paper
Class: XII Session: 2023-24
Computer Science (083)

Time allowed: 3 Hours Maximum Marks: 70

General Instructions:
 Please check 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 to 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.

Q No. Questions Marks


Section-A (18 Marks)
1 Which of the following is an invalid identifier to be used in Python? 1

a. per%marks
b. _for
c. While
d. true
2 What is the correct way to add an element to the end of a list in 1
Python?

a. [Link](element)
b. [Link](element)
c. [Link](element)
d. [Link](element)
3 What will be the output of 1
print("Welcome To My Blog"[2:6] + "Welcome To My
Blog"[5:9])

a. Lcomme
b. lcomme T
c. lcomme To
d. lcomme
4 Which of the following statements is false? 1

a. A try-except block can have more than one except statement


b. One block of except statement cannot handle multiple exceptions
c. The finally block is always executed
d. When 1 == "1" is executed, no exception is raised
5 Which of the following statement(s) would give an error during the 1
execution of the following code?

R = {'pno':52,'pname':'Virat', 'expert':['Badminton','Tennis'] ,'score':(77,44)}


print(R) #Statement 1
1
R['expert'][0]='Cricket' #Statement 2
R['score'][0]=50 #Statement 3
R['pno']=50 #Statement 4

a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4
6 Which pickle module method is used to write a Python object to a 1
binary file?

a. save()
b. serialize()
c. store()
d. dump()
7 Given the following dictionaries 1
dict_student = {"rno" : "53", "name" : 'Rajveer Singh'}
dict_marks = {"Accts" : 87, "English" : 65}

Which statement will append the contents of dict_marks in


dict_student?

a. dict_student + dict_marks
b. dict_student.add(dict_marks)
c. dict_student.merge(dict_marks)
d. dict_student.update(dict_marks)
8 Which of the following is not a component of the math module in 1
Python?

a. ceil()
b. mean()
c. fabs()
d. pi
9 What will be the output of the following code? 1
L=["One , Two", "Three", "Four"]
print(len(L)/2*len(L[0]))

a. 6.5
b. 13
c. 13.5
d. 6.0
10 Expand the following terms: 1
(i) PPP
(ii) VoIP
11 Which SQL operator performs pattern matching? 1

a. BETWEEN operator
b. LIKE operator
c. EXISTS operator
d. =

2
12 Which Python function is used for displaying only one result set from 1
SQL table in a database?

a. fetch1()
b. fetchno()
c. fetchall()
d. fetchone()
13 Which of the following file opening mode in Python, generates an 1
error if the file does not exist?

a. a
b. r
c. w
d. w+
14 The correct syntax of seek() is: 1
a. file_object.seek(offset [, reference_point])
b. seek(offset [, reference_point])
c. seek(offset, file_object)
d. seek.file_object(offset)
15 Which of the following statements is false? 1

a. SMTP and POP protocols are used in email communication.


b. URL of a page is not always the same as its domain name.
c. HTTPS is safer than HTTP.
d. Interlinking of collection of webpages is called Internet.
16 Fill in the blank: 1
_________ protocol provides access to services hosted on a remote
computer.

a. FTP
b. PPP
c. Telnet
d. SMTP
Q17 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): For changes made to a variable defined within a 1
function to be visible outside the function, it should be declared as
global.
Reasoning (R): Variables defined within a function are local to that
function by default, unless explicitly specified with the global
keyword.
18 Assertion (A): A binary file in python is used to store collection 1
objects like lists and dictionaries that can be later retrieved in their
original form using pickle module.

3
Reasoning (A): Binary files are just like normal text files and can be
read using a text editor like Notepad.
Q No. Questions Marks
Section-B (14 Marks)
19 Write two advantages and two disadvantages of circuit switching. 2
OR
Differentiate between Web server and web browser. Write the names
of any two web browsers.
20 Rewrite the following code in Python after removing all the syntax 2
errors. Underline each correction done in the code.

num1, num2 = 10, 45


While num1 % num2 == 0
num1+= 20
num2+= 30
Else:
print('hello')

21 Write a function dispBook(BOOKS) in Python, that takes a dictionary 2


BOOKS as an argument and displays the names in uppercase of those
books whose name starts with a consonant.

For example, Consider the following dictionary


BOOKS = {1:"Python", 2:"Internet Fundamentals ", 3:"Networking ",
4:"Oracle sets", 5:"Understanding HTML"}

The output should be:


PYTHON
NETWORKING
OR
Write a Python Program containing a function FindWord(STRING,
SEARCH), that accepts two arguments : STRING and SEARCH, and
prints the count of occurrence of SEARCH in STRING. Write
appropriate statements to call the function.

For example, if STRING = "Learning history helps to know about


history with interest in history" and SEARCH = 'history', the function
should display
The word history occurs 3 times.
22 What will be the output of the following code? 2

L = [5,10,15,1]
G = 4
def Change(X):
global G
N=len(X)
for i in range(N):
X[i] += G

Change(L)

for i in L:
print(i,end='$')

4
23 Write a suitable Python statement for each of the following tasks 2
using built-in functions/methods only:
i To delete an element Mumbai:50 from Dictionary D.
ii To display words in a string S in the form of a list
OR
Write a Python Program to display alternate characters of a string
my_str.
For example, if my_str = "Computer Science"
The output should be Cmue cec
24 Differentiate between % (percentage) and _(underscore) characters 2
used with the LIKE operator in SQL with appropriate examples.
OR
Differentiate between DROP and DELETE commands in SQL with
appropriate examples.
25 Consider the following two commands with reference to a table, 2
named Employee having a column named Department:
(a) Select count(Department) from Employee;
(b) Select count(*) from Employee;

If these two commands are producing different results,


(i) What may be the possible reason?
(ii) Which command (a) or (b) might be giving a higher value?
Q No Questions Marks
Section-C (15 Marks)

26 (a) Consider the table, BOOK and MEMBER given below: 3

TABLE : BOOK
CODE BNAME TYPE
F101 The priest Fiction
L102 Easy Python Programming
C101 Juman Ji Thriller
F102 Untold Story Fiction
C102 War Stories Comic

Table: MEMBER
MNO MNAME CODE ISSUEDATE
M101 SNEH SINHA L102 2022-10-13
M103 SARTHAK F102 2021-02-23
M102 SARA KHAN C101 2022-06-12

What will be the output of the following statement?


SELECT * FROM BOOK NATURAL JOIN MEMBER;

(b) Write the output of the queries (i) to (iv) based on the table
Table: Employee
EID Name DOB DOJ Salary Project
E01 Ranjan 1990-07-12 2015-01-21 150000 P01
E02 Akhtar 1992-06-21 2015-02-01 125000 P04
E03 Muneera 1996-11-15 2018-08-19 135000 P01
E04 Alex 1991-10-25 2018-10-19 75000 P02
E05 Satyansh 1993-12-16 2018-10-19 85000 P04

5
i SELECT NAME, PROJECT FROM EMPLOYEE ORDER BY NAME DESC;
ii SELECT NAME, SALARY FROM EMPLOYEE WHERE NAME LIKE 'A%';
iii SELECT NAME, DOJ FROM EMPLOYEE WHERE SALARY BETWEEN
100000 AND 200000;
iv SELECT * FROM EMPLOYEE WHERE PROJECT = 'P01';
27 (a) Consider the following tables – FACULTY and COURSES : 3
Table: FACULTY
FID FNAME LNAME JOINDATE SALARY
F01 Anishma Garg 2000-12-14 32000
F03 Bhumi Goel 2001-08-10 15000
F04 Neha Verma 2000-05-17 27000
F05 Meenu Sharma 2006-07-11 30000

Table: COURSES
C_ID FID CNAME FEES
C11 F01 Grid Computing 40000
C12 F04 Python 17000
C13 F03 C++ 8000
C14 F04 Computer Network 15000
C15 F01 HTML 12000
C16 F05 Data Science NULL

What will be the output of the following statement?


i SELECT FID, MIN(FEES), MAX(FEES) FROM COURSES GROUP BY
FID;
ii SELECT AVG(SALARY) FROM FACULTY WHERE FNAME LIKE '%a';
iii SELECT FNAME, CNAME FROM FACULTY F, COURSES C WHERE
[Link]=[Link] AND [Link]='F04';
iv SELECT FNAME, CNAME , FEES FROM FACULTY F , COURSES C
WHERE [Link] = [Link] AND FEE>15000;

(b) Write the name of the command to display the structure of a


table in a database.
28 Write a function COUNT() in Python to read from a text file 3
'[Link]' and display the count of the letter 'e' in each
line
Example: If the file content is as follows:
Gratitude is a humble heart's radiant glow,
A timeless gift that nurtures and bestows.
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.

The COUNT() function should display the output as:


Line 1 : 3
Line 2 : 4
Line 3 : 6
Line 4 : 1
OR
Write a function Start_with_I() in Python, which should read a
text file '[Link]' and then display lines starting with 'I'.
Example: If the file content is as follows:
Gratitude is a humble heart's radiant glow,
A timeless gift that nurtures and bestows.
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.

6
Then the output should be
It's the appreciation for the love we're shown,
In moments big and small, it's truly known.
29 Navdeep creates a table RESULT with a set of records to maintain the 3
marks secured by students in Sem1, Sem2, Sem3, and their divisions.
After the creation of the table, he entered data of 7 students in the
table.
ADNO ROLLNO SNAME SEM1 SEM2 DIVISION
123 101 KARAN 366 410 I
245 102 NAMAN 300 350 I
128 103 ISHA 400 410 I
129 104 RENU 350 357 I
234 105 ARPIT 100 75 IV
187 106 SABINA 100 205 II
181 107 NEELAM 470 450 I

Based on the data given above answer the following questions:


i Identify the columns which can be considered as candidate
keys?
ii If 2 more columns are added and 3 rows are deleted from the
table result, what will be the new degree and cardinality of the
above table?
iii Write a statement to increase the SEM2 marks by 3% for the
students securing marks between 70 to 100.
30 Given a Dictionary Stu_dict containing marks of students for three 3
test-series in the form Stu_ID:(TS1, TS2, TS3) as key-value pairs.
Write a Python program with the following user-defined functions to
perform the specified operations on a stack named Stu_Stk

(i) Push_elements(Stu_Stk, Stu_dict) : It allows pushing


IDs of those students, from the dictionary Stu_dict into the stack
Stu_Stk, who have scored more than or equal to 80 marks in the TS3
Test.
(ii) Pop_elements(Stu_Stk): It removes all elements present
inside the stack in LIFO order and prints them. Also, the function
displays 'Stack Empty' when there are no elements in the stack.
Call both functions to execute queries.

For example:
If the dictionary Stu_dict contains the following data:
Stu_dict ={5:(87,68,89), 10:(57,54,61), 12:(71,67,90),
14:(66,81,80), 18:(80,48,91)}

After executing Push_elements(), Stk_ID should contain


[5,12,14,18]

After executing Pop_elements(), The output should be:


18
14
12
5
Stack Empty

7
Q No. Questions Marks
Section-D (8 Marks)
31 Create a function maxsalary() in Python to read all the records 4
from an already existing file [Link] which stores the records
of various employees working in a department. Data is stored under
various fields as shown below:
E_code E_name Scale Salary
A01 Bijesh Mehra S4 65400
B02 Vikram Goel S3 60000
C09 Suraj Mehta S2 45300
…… …… …… ……
Function should display the row where the salary is maximum.
Note: Assume that all employees have distinct salary.
32 Consider a binary file '[Link]' that stores information 4
about products using tuple with the structure (ProductID,
ProductName, Quantity, Price). Write a Python function
expensiveProducts() to read the contents of
'[Link]' and display details of products with a price
higher than Rs. 1000. Additionally, calculate and display the total
count of such expensive products.

For example: If the file stores the following data in binary format
(1, 'ABC', 100, 5000)
(2, 'DEF', 250, 1000)
(3, 'GHI', 300, 2000)
then the function should display
Product ID: 1
Product ID: 3
Total expensive products: 2
Q No. Questions Marks
Section-E (15 Marks)
33 Fun Media Services Ltd is an event planning organization. It is 5
planning to set up its India campus in Mumbai with its head office in
Delhi. The Mumbai campus will have four blocks/buildings -
ADMIN, DECORATORS, FOOD, and MEDIA.
You as a network expert need to suggest the best network-related
solutions for them to resolve the issues/problems mentioned in points
(i) to (v), keeping in mind the distances between various
blocks/buildings and other given parameters.

8
Shortest distance between various buildings:
FROM – TO DISTANCE
ADMIN TO DECORATORS 90 meters
ADMIN TO MEDIA 75 meters
ADMIN TO FOOD 50 meters
DECORATORS TO FOOD 65 meters
DECORATORS TO MEDIA 50 meters
FOOD TO MEDIA 45 meters
DELHI Head Office to MUMBAI 1475 KM
Campus

The number of computers at various buildings is as follows:


BUILDING NUMBER OF COMPUTERS
ADMIN 110
DECORATORS 75
MEDIA 12
FOOD 20

i. Suggest the most appropriate location of the server inside the


MUMBAI campus (out of the 4 buildings). Justify your answer.
ii. Draw the cable layout to efficiently connect various buildings
within the MUMBAI campus.
iii. Which hardware device will you suggest to connect all the
computers within each building?
iv. Which of the following will you suggest to establish online
face-to-face communication between the people in the Admin
Office of the MUMBAI campus and the DELHI Head Office?
a. Cable TV
b. Email
c. Video Conferencing
d. Text Chat
v. What type of network (out of PAN, LAN, MAN, WAN) will
be set up in each of the following cases?
a. The Mumbai campus gets connected with the Head Quarter
in Delhi
b. The computers connected in the MUMBAI campus
34 i. Mention any two differences between seek() and tell(). 2+3=5
ii. Consider a file [Link] containing multiple records. The
structure of each record is as shown below:
[Fno, FName, Fare, Source, Destination]
Write a function COPY_REC() in Python that copies all those
records from [Link] where the source is DELHI and the
destination is MUMBAI, into a new file [Link]
OR
i. Mention any two differences between binary files and csv files?
ii. Consider a Binary file [Link] containing a dictionary
having multiple elements. Each element is in the form
BNO:[BNAME,BTYPE,PRICE] as key:value pair
where
BNO – Book Number
BNAME – Book Name
BTYPE - Book Type
PRICE – Book price

9
Write a user-defined function, findBook(price), that accepts
price as parameter and displays all those records from the
binary file [Link] which has a book price more than or equal
to the price value passed as a parameter.
35 i. Define the term constraint with respect to RDBMS. Give a 5
suitable example.
ii. Sameera maintains a database named STORE which contains a
table named ITEM with the structure given below:
• Ino(Item number )- integer
• Iname(Item Name) – string
• Price (Item Price) – float
• Discount (Discount) – float
Note the following to establish connectivity between Python
and MySQL:
• Username - root
• Password - tiger
• Host - localhost
Help her to remove the record from the table ITEM for a particular
value of item name input by the user.
import [Link] as mysql
con1= [Link](host='localhost', user='root', password=
'__', database='STORE') #Statement-1
mycursor = ________ #Statement-2
item_name = input("Enter the Item name to remove the record : ")
query = ______________ #Statement-3
[Link](query)
con1.____ #Statement-4
print('Data Deleted successfully')
[Link]()

With reference to the above code, answer the following questions


a) Complete statement 1 to establish the connection with the
database.
b) Write statement 2 to create the cursor object.
c) Complete statement 3 to remove the record from the table
ITEM based on the item name entered by the user
d) Complete statement 4 to save the changes in the table.
OR
i. Write one difference between the alternate key and the
candidate key.
ii. A table named ITEM is created in a database STORE. The table
contains multiple columns whose details are as shown below:
 Ino(Item number )- integer
 Iname(Item Name) – string
 Price (Item Price) – float
 Discount (Discount) – float

Note the following to establish connectivity between Python


and MySQL:
 Username - root
 Password - tiger
 Host - localhost
However, the table is to be interfaced with Python to perform
certain tasks. The incomplete code is given below:
10
______ #Line 1
con1= [Link](host='localhost', user = 'root', password =
'tiger', database='STORE')
mycursor = con1.____ #Line 2
query = 'SELECT * FROM ITEM where Price > {}'.format(___) #Line3
[Link](query)
data = mycursor.___ #Line 4
for rec in data:
print(rec)
[Link]()
i. Complete line 1 to import the appropriate module.
ii. Complete Line 2 to create the cursor object
iii. Complete the query given in Line 3 to display details of all such
items from the table ITEMS whose price is more than 5000.
iv. Complete Line 4 to extract all the records.

11
CBSE Additional Practice Question Paper
Class: XII Session: 2023-24
Computer Science (083)
Marking Scheme

Q No. Answer Total


Marks

1 a. per%marks 1
2 b. [Link](element) 1
3 b. lcomme T 1
4 b. One block of except statement cannot handle multiple exceptions 1
5 c. Statement 3 1
6 d. dump 1
7 d. dict_student.update(dict_marks) 1
8 b. mean() 1
9 c. 13.5 1
10 PPP – Point to Point Protocol 1
VoIP - Voice Over Internet Protocol
11 b. LIKE operator 1
12 d. fetchone 1
13 b. r 1
14 a. file_object.seek(offset [, reference_point]) 1
15 d. Interlinking of collection of webpages is called Internet. 1
16 c. TelNet 1
17 a. Both A and R are true and R is the correct explanation for A 1
18 c. A is True but R is False 1
19 Advantages: 2
1) A dedicated communication channel increases the quality of
communication.
2) Suitable for long continuous communication.

Disadvantages:
1) Resources are not utilized fully.
2) The time required to establish the physical link between the two stations is
too long.

½ mark for each advantage and disadvantage

OR

Web browser
Purpose: Receives and displays web content.
1
Function: Initiates requests to web servers, and receives and displays content
for users.
Web server
Purpose: Delivers web content to clients.
Function: Listens to incoming requests, processes them, and sends requested
content to the client.

Name of Web browsers: Google Chrome, Mozilla Firefox

1 mark for any one correct difference and 1/2 mark for each two correct
examples
20 num1, num2 = 10, 45 2
while num1 % num2 == 0:
num1+= 20
num2+= 30
else:
print('hello')

½ mark for while


½ mark for :
½ mark for correct indentation (inside the block of while)
½ mark for else
21 def dispBook(BOOKS): 2
for key in BOOKS:
if BOOKS[key][0] not in "AEIOUaeiou":
print(BOOKS[key].upper())

BOOKS = {1:"Python",2:"Internet Fundamentals ",3:"Networking


",4:"Oracle sets",5:"Understanding HTML"}
dispBook(BOOKS)

½ mark for for loop


1 mark for if condition
½ mark for display in upper case
OR
def FindWord(STRING,SEARCH):
return (STRING . count (SEARCH) )

str = input('Enter String : ')


word = input('Enter word to search : ')
print('The word', word, 'occurs', FindWord(str,word), 'times')

½ mark for input


½ mark for print statement
1 mark for counting the word and returning the value
22 9$14$19$5$ 2

½ mark for 9$
½ mark for 14$
½ mark for 19$
½ mark for 5$
23 i. del D['Mumbai'] 2
1 mark for correct answer

2
ii. print([Link]())
1 mark for correct answer
OR
my_str = "Computer Science"
alternate_chars = my_str[::2]
print(alternate_chars)

1.5 mark for logic of alternate characters


½ mark for printing alternate characters
24 % (Percentage): 2
 Matches any sequence of characters (including empty sequence).
 Example: LIKE 'T%' matches all those strings starting with the letter 'T'.
The string with just 1 character 'T' will also be considered.

_ (Underscore):
 Matches a single character.
 Example: LIKE '_ _T' on the other hand will search for a three letter
string, whose 3rd letter is 'T'. At first two places any two character can
appear.

1 mark for one correct difference. 1/2 mark each for correct example of each.
OR

DROP is a DDL command in SQL and can be used to remove tables (or
database).
Example: 'DROP TABLE STUDENT;' will remove the table STUDENT from
the database.

DELETE is a DML command used to remove or delete rows/records from a


table.
Example: 'DELETE FROM STUDENT WHERE PER < 33;' will remove all
those records from the table STUDENT where the percentage is less than 33.

1 mark for one correct difference. 1/2 mark each for correct example of each.
25  COUNT(*) returns the count of all rows in the table, whereas COUNT() 2
is used with Column_Name passed as an argument and counts the number
of non-NULL values in a column that is given as an argument. Hence the
result may differ.
 The SQL command with COUNT(*) may have higher value as it count
all rows in the table.

1 mark for suitable reason


1 mark for mentioning correct command
26 (a) 3

CODE BNAME TYPE MNO MNAME ISSUEDATE


L102 Easy Python Programming M101 SNEH SINHA 2022-10-13
F102 Untold Story Fiction M103 SARTHAK 2021-02-23
C101 Juman Ji Thriller M102 SARA KHAN 2022-06-12

1 mark for correct answer

3
(b)
(i)
NAME PROJECT
Satyansh P04
Ranjan P01
Muneera P01
Alex P02
Akhtar P04
½ mark for correct output

(ii)
NAME SALARY
Akhtar 125000
Alex 75000

½ mark for correct output

(iii)
NAME DOJ
Ranjan 2015-01-21
Akhtar 2015-02-01
Muneera 2018-08-19
½ mark for correct output

(iv)
Eid Name DOB DOJ Salary Project
E01 Rannja 1990-07-12 2015-01-21 150000 P01
E03 Muneera 1996-11-15 2018-08-19 135000 P01
½ mark for correct output
27 (a) 3
(i)
FID MIN(FEES) MAX(FEES)
F01 12000 40000
F04 15000 17000
F03 8000 8000
F05 NULL NULL
½ mark for correct answer

(ii)

AVG(SALARY)
29500
½ mark for correct answer

(iii)
FNAME CNAME
Neha Python
Neha Computer Network
½ mark for correct answer
(iv)

FNAME CNAME FEES


Anishma Grid Computing 40000
Neha Python 17000
½ mark for correct answer

4
(b)
DESC or DESCRIBE command
1 mark for correct answer
28 def Count(): 3
F=open('[Link]')
T=[Link]()
X=1
for i in T:
print('Line',X,':',[Link]('e'))
X=X+1
[Link]()
Count()

½ mark for function header


½ mark for opening and closing the file
½ mark for reading lines
½ mark for loop
½ mark for count function/or any other alternate correct statement(s)
½ mark for counter

OR

def Start_with_I():
F=open('[Link]')
T=[Link]()
for i in T:
if i[0] in 'Ii':
print(i,end='')
[Link]()
Start_with_I()

½ mark for function header


½ mark for opening and closing the file
½ mark for reading lines
½ mark for loop
½ mark for if condition
½ mark for print statment
29 (i) Candidate Keys : ADMNO, ROLLNO 3

1 mark for correctly writing both names of candidate keys. OR ½ mark for
specifying any one candidate key correctly.

(ii) Degree-8, Cardinality=4

½ mark for degree and ½ mark for cardinality

(iii) Update result set SEM2=SEM2+.03*SEM2 where SEM2 between 70


and 100;

½ mark for writing Update result set part correctly


½ mark for writing SEM2=SEM2+.03*SEM2 where SEM2 between 70 and
100; correctly.
30 Stu_dict={5:(87,68,89), 10:(57,54,61), 12:(71,67,90), 3
14:(66,81,80), 18:(80,48,91)}

5
Stu_Stk=[]

def Push_elements(Stu_Stk, Stu_dict):


for Stu_ID, marks in Stu_dict.items():
if marks[2]>=80:
Stu_Stk.append(Stu_ID)

def Pop_elements(Stu_Stk):
while len(Stu_Stk)>0:
print(Stu_Stk.pop())
if not Stu_Stk:
print('Stack Empty')

Push_elements(Stu_Stk, Stu_dict)
Pop_elements(Stu_Stk)

1.5 marks for correct implementation of Push_elements()


1.5 marks for correct implementation of Pop_elements()
31 import csv 4
def maxsalary():
f=open('[Link]', 'r')
reader=[Link](f)
skip_header = True
max= 0
for row in reader:
if skip_header:
skip_header = False
else:
if(int(row[3])>max):
max=int(row[3])
rec=row
print('Row with the highest salary : ', rec)
[Link]()
maxsalary()

½ mark for importing module


½ mark for function definition
½ mark for opening and closing file
½ for reader object
½ for skipping first row (i.e. header)
1 mark for calculating maximum salary
½ mark for displaying record having maximum salary
32 import pickle 4
def expensiveProducts():
with open('[Link]', 'rb') as file:
expensive_count = 0
while True:
try:
product_data = [Link](file)
product_id, product_name, quantity, price = product_data
if price > 1000:
print("Product ID:", product_id)
expensive_count += 1
except EOFError:
break

print("Total expensive products: ", expensive_count)

expensiveProducts()

½ mark for function definition

6
½ mark for opening and closing file
½ mark for correct try and except block
1.5 mark identifying and displaying details of expensive products
1 mark for displaying count of expensive products
33 i. The most appropriate location of the server inside the MUMBAI 5
campus is ADMIN building due to the maximum number of computers
in it.
½ mark for mentioning the branch and ½ mark for proper justification

ii. Cable Layout


Star Topology (Based on Bus Topology (Based on
server location) minimum distance between
branches)

1 mark for drawing any valid cable layout

iii. Switch or Hub


1mark for suggesting the correct device

iv. c. Video Conferencing


1 mark for correct answer

v.
(a) WAN
(b) LAN
½ mark for mentioning WAN and ½ mark for mentioning LAN
34 i. 5
seek() tell()
Purpose Repositions the file pointer to a Returns the current
specific location within a file position of the file
pointer
Syntax seek(offset [,reference point]) tell()
Parameters Requires specifying the offset Requires no
and an optional reference point parameters

2 marks for mentioning two correct differences.


OR
1 marks for mentioning only one correct differences.
ii.
import pickle
def COPY_REC():
In_file = open('[Link]','rb')
out_file = open('[Link]','wb')
try:
7
while True:
data = [Link](In_file)
if data[3] == 'DELHI' and data[4] == 'MUMBAI':
[Link](data,out_file)
except:
In_file.close()
out_file.close()

COPY_REC()

½ mark for function definion


½ mark for correctly opening and closing file
½ mark for correct try and except block
1.5 marks for writing required data in [Link]

OR
i.
Binary CSV
1. pickle module to be used 1. csv module is used
2. Data is stored in binary 2. Data is stored in tabular
format(0s and 1s) and is not fashion and comma
in human readable form using separated by default. The
any plain text editor. file can be read by any
spreadsheet software or text
editor.
3. File extension .dat/.pdf/.exe 3. File extension .csv
etc.

2 marks for mentioning two correct differences.


OR
1 marks for mentioning only one correct differences.

ii.

import pickle

def findBook(price):
with open('[Link]', 'rb') as file:
while True:
try:
book_record = [Link](file)
for item in book_record:
book_price = book_record[item][2]
if book_price >= price:
print(item, book_record[item])
except EOFError:
break

findBook(50)

½ mark for function definion


½ mark for correctly opening and closing file
½ mark for correct try and except block
1.5 marks for displying required records
35 (i) 5

8
SQL constraints are used to specify rules for the data in a table. Constraints
are used to limit the type of data that can go into a table.
Constraints –
NOT NULL - Ensures that a column cannot have a NULL value
UNIQUE - Ensures that all values in a column are different
PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely
identifies each row in a table

½ mark for correct definition, ½ mark for correct example (anyone)


(ii)
a) password='tiger'
b) mycursor = [Link]()
c) query = 'delete from ITEM where Iname = "{}" '.format.(item_name)
d) [Link]()

1 mark for each correct statement

OR
(i)
Candidate Key: A candidate key is a set of attributes in a relation that can
uniquely identify each tuple (row). A relation can have multiple candidate
keys, but only one of them is chosen as the primary key.
Alternate Key: An alternate key is a candidate key that is not selected as the
primary key.

1 mark for any one correct difference.

(ii)
a) import [Link] as mysql
b) mycursor = [Link]()
c) query = 'SELECT * FROM ITEM where Price > {}'.format(5000)
d) data = [Link]()

1 mark for each correct statement

You might also like