CS

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

KENDRIYA VIDYALAYA SANGATHAN: BHUBANESWAR REGION

FIRST PRE-BOARD EXAMINATION 2024-25


CLASS XII - 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.

SECTION-A (21 x1=21M)


1 State True or False: 1
A string can be surrounded by three sets of single quotation marks or by three sets of double
quotation marks.
2 If following will be executed then what will be the output- 1
s="Kendriya Vidyalaya Sangathan"
L=s.split()
S1=L[0].upper() + ‘-‘+L[1].lower()+ ‘@’+L[2].capitalize()
a) KENDRIYA-vidyalaya@Sangathan
b) KENDRIYA-VIDYALAYA@SANGATHAN
c) Kendriya-Vidyalaya@Sangathan
d) KENDRIYA-vidyalaya@sangathan
3 What will be the output of the following expression if the value of a=0, b=1 and c=2? 1
print(a and b or not c )
(a) True (b) False (c) 1 (d) 0
4 Consider the statements given below and then find the correct output . 1
pride="Malayalam@3"
print(pride[-2:2:-2])
5 What will be the output of the following Python code? 1
T1=(1,2,[1,2],3)
T1[2][1]=3.5
print(T1)
(a) (1,2,[3.5,2],3) (b) (1,2,[1,3.5],3) (c) (1,2,[1,2],3.5) (d) Error Message
6 What will be the output of the following Python statements? 1
D={‘BHUSHAN’:90, ‘SAKSHI’:96,’RANJIT’:85}
print(‘RANJIT’ in D, 96 in D, sep=’@’)
a. True@True
b. False@True
c. True@False
d. False@False
7 What will be the output of the following code? 1
s = [3,0,[2,1,2,3],1]
print(s[s[len(s[2])-2][1]])
a.0 b. 1 c. [2,1,2,3] d. 2
8 Which of the following statement(s) will raise an exception? 1
Sales = {"Printer":25000,"Mouse":750 } # Statement 1
print (Sales[750]) # Statement 2
Sales ["Printer"]=12500 # Statement 3
print (Sales.pop()) # Statement 4
print (Sales) # Statement 5
(a) Statement 2
(b) Statement 3
(c) Statement 4
(d) Statements 2 and 4
9 State whether the following statement is True or False: 1
An exception may be raised even if the program is syntactically correct.
10 Which of the following will delete key-value pair for key = “Red” from a dictionary COLOR? 1
a. delete COLOR("Red") b. del COLOR["Red"]
c. del.COLOR["Red"] d. COLOR.del["Red"]
11 tell() is a method of: 1
(a) pickle module (b) csv module (c) file object (d) seek( )
12 def func(S): 1
m= ‘ ‘
for i in range(0,len(S)):
if S[i].isalpha( ):
m=m+S[i].upper( )
elif S[i].isdigit( ):
m=m+’0’
else:
m=m+”#”
print(m)
func(“Python 3.9”)
(i) python0#0#
(ii) Python0#0#
(iii) PYTHON#0#0
(iv) PYTHON0#0#
13 The structure of the table/relation can be displayed using __________ command. 1
(a) view (b) describe (c) show (d) select
14 Fill in the blank: 1
Number of records/ tuples/ rows in a relation or table of a database is referred to as ________
(a) Domain (b) Degree (c) Cardinality (d) Integrity
15 Choose correct SQL query which is expected to delete all rows of a table emp without deleting its 1
structure.
a)DELETE TABLE;
b)DROP TABLE emp;
c)REMOVE TABL emp;
d)DELETE FROM emp;
16 Which command is used to change table structure in SQL? 1
17 Shanu wants to transfer pictures from her mobile phone to her laptop. She uses Bluetooth 1
Technology to connect two devices. Which type of network will be formed in this case?
a. PAN b. LAN c. MAN d. WAN
18 What out of the following, will you use to have an audio-visual chat with an expert sitting in a far- 1
away place to fix-up a technical issue?
(a) VoIP (b) email (c) FTP (d) SMTP
19 Which devices modulates digital signals into analog signals that can be sent over traditional 1
telephone lines?
No. 20 and 21 are ASSERTION ( A ) and REASONING ( R ) based questions.
Mark the correct choice as:
a. Both A and R are true and R is the correct explanation for A.
b. Both A and R are true and R is not correct explanation for A.
c. A is true but R is false.
d. A is false but R is true.
20 Assertion(A):Key word arguments are related to the function calls 1
Reason(R): When you use keyword arguments in a function call, the caller identifies the
arguments by the parameter name
21 Assertion (A): A foreign key in the relational data model is a set of attributes in one 1
relation that references the primary key of another relation.
Reason (R): Foreign keys are used to establish relationships between tables.

SECTION-B (7 x 2 =14M)

22 Rewrite the following code in python after removing all syntax errors. Underline each 2
correction done in the code:
Def Calc(a):
for i in (0,a):
if i%2 =0:
s=s+1
else if i%5= =0
m=m+2
else:
n=n+i
print(s,m,n) Calc(15)
23 Give two examples of each of the following: 2
(I) keywords (II) Mutable Datatypes
24 Write a suitable Python statement for each of the following tasks using built-in 2
functions/methods only:
a) To delete an element Mumbai:50 from Dictionary D.
b) To display words in a string S in the form of a list
OR
a)To insert an element 100 at the Second position, in the list L 1
b) To sort the elements of list L1 in ascending order.
25 What possible outputs(s) are expected to be displayed on screen at the time of execution of 2
the program from the following code? Also specify the maximum values that can be assigned
to each of the variables BEG and END.
import random
heights=[10,20,30,40,50]
beg=random.randint(0,2)
end=random.randint(2,4)
for x in range(beg,end):
print(heights [x],end=’@’)
(a) 30 @
(b) 10@20@30@40@50@
(c) 20@30
(d) 40@30@
26 Explain the Relational Database Management System terminologies- Degree and Attribute of 2
a relation. Give example to support your answer
OR
Explain the use of ‘Foreign Key’ in a Relational Database.Give an example to support your
answer.
27 Give difference between DROP and DELETE command in SQL 2
OR
Name the aggregate functions which work only with numeric data, and those that work with
any type of data.
28 Differentiate between Star Topology and Bus Topology. Write two points of difference. 2
OR
(i) Expand the following terms:
POP3 , URL
(ii) Give one difference between XML and HTML.
SECTION-C (3 x 3 = 9 M)

29 Write a user defined function in python that displays the number of lines starting with word 'It' 3
in the file Poetry.txt
OR
write a user defined function Transfer() that copies a text file "source.txt" onto “destination.txt"
barring the lines starting with # sign.
30 A list named as Record contains following format of for students: [student_name, class, city]. 3
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
OR
Mr. Rakesh has created a list of elements. Help him to write a program in python with
functions, PushElement(element) and PopElement(element) to add a new element and
delete an element from a List of element Description, 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 7.
For eg:if LIST=[1,9,12,48,56,63]
then stack content will be 63 56
31 Ridhi is working in a mobile shop and assigned a task to create a table MOBILES with record 3
of mobiles as Mobile code, Model, Company, Price and Date of Launch. After creation of the
table, she has entered data of 5 mobiles in the MOBILES table.
MOBILES

MCODE MODEL COMPANY PRICE DATE_OF_LAUNCH


M01 9PRO REALME 17000 2021-01-01
M02 NOTE11 MI 21000 2021-10-12
M03 10S MI 14000 2022-02-05
M04 NARZO50 REALME 13000 2020-05-01
M05 iPHONE12 APPLE 70000 2021-07-01
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as Primary key.
(ii) Write the degree and cardinality of the above table, after removing one column
and two more record added to the table.
(iii) Add a new column GST with data type integer to the table.
OR
i) Insert the value of GST in the new column as 18% of PRICE
ii) To insert a new record of mobile as MobileCode – M06, Company Apple, Model-
iPHONE13, Price-110000 and Date of launch – ‘2022-03-01’.
iii) To delete the record of mobile with model as NARZO50.

SECTION-D (4 x 4 = 16 M)

32 i. When is TypeError exception raised in Python?


ii. Give an example code to handle TypeError ? The code should display the message "
Invalid input. Please Input a valid number " in case of TypeError exception, and the
message "Some error occurred" in case of any other exception.
OR
i.What is the use of a raise statement ?
ii.Write a code to accept two numbers and display the quotient. Appropriate exception should
be raised if the user enters the second number (denominator) as zero (0).
33 A CSV file ‘empdata.csv’ consists of a list with field elements as Eid, Ename, Salary and 4
City to store employee id , employee name, employee salary and city. Write a Program in
Python that defines and calls the following user defined functions:
SEARCH()- To display the records of the employees whose salary is more than 25000.
COUNTROW() – To count the number of records present in the CSV file named
‘empdata.csv’.
34 Consider the following tables and answer the questions a and b: 4
Table: Garment
GCode GName Rate Qty CCode

G101 Saree 1250 100 C03


G102 Lehanga 2000 100 C02
G103 Plazzo 750 105 C02
G104 Suit 2000 200 C01
G105 Patiala 1850 105 C01

Table: Cloth
CCode CName
C01 Polyester
C02 Cotton
C03 Silk
C04 CottonPolyester
Write SQL queries for the following:
i. Display unique quantities of garments.
ii. Display sum of quantities for each CCODE whose numbers of records are more than 1.
iii. Display GNAME, CNAME, RATE whose garments name starts with S.
iv. Display average rate of garment whose rate ranges from 1200 to 2000 (both values
included)
35 A table named `EMPLOYEES` is created in a database named `COMPANY`. The table
contains multiple columns whose details are as shown below:
- `EmpID` (Employee ID) - integer
- `EmpName` (Employee Name) - string
- `Salary` (Employee Salary) - float
- `Department` (Employee Department) - string
Note the following to establish connectivity between Python and MySQL:
- Username: root
- Password: school123
- Host: localhost
Write the following Python function to perform the specified operation: ChecknDisplay():
To input details of an employee and store it in the table EMPLOYEES. The function should
then retrieve and display all records display details of all such employees from the table
EMPLOYEES whose salary is more than 50000.

SECTION-E (2 x 5 = 10 M)

36 Shivam Sen is a programmer in school , He needs to manage the records of various 5


students. For this he wants the following information of each student to be stored:
i. Mention any two difference between binary and csv files ?
ii. AddStudents() is a function to input the data of a students and append it in the file
STUDENT.DAT containing student information – roll number, name and marks (out of 100)
of each student.
iii.GetStudents() is a function Write a function to read the data from the file to display the
name and percentage of those students who have a percentage greater than 75. In case
there is no student having percentage > 75, the function displays an appropriate message.
37 Anant National University is setting up its academic blocks at Ahmedabad and is planning to 5
set up a network. The University has 3 academic blocks and one Human Resource Center
as shown in the diagram below: Study the following structure and answer questions (a) to (e)

Technology Block Business Block

HR Center Law Block

Center to Center distances between various blocks/center is as follows:


Law Block to business Block - 40m
Law block to Technology Block - 80m
Law Block to HR center - 105m
Business Block to technology Block - 30m
Business Block to HR Center - 35m
Technology block to HR center - 15m

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


BLOCK NO.OF COMPUTERS
Law Block 15
Technology Block 40
HR center 115
Business Block 25

a) Suggest the most suitable place (i.e., Block/Center) to install the server of this University
with a suitable reason.
b) Suggest an ideal layout for connecting these blocks/centers for a wired connectivity.
c) Which device will you suggest to be placed/installed in each of these blocks/centers to
efficiently connect all the computers within these blocks/centers?
d) Suggest the placement of a Repeater in the network with justification.
e) The university is planning to connect its admission office in Delhi, which is more than
1250km from university. Which type of network out of LAN, MAN, or WAN will be formed?
Justify your answer.
KENDRIYA VIDYALAYA SANGATHAN: BHUBANESWAR REGION
FIRST PRE-BOARD EXAMINATION 2024-25
CLASS XII - COMPUTER SCIENCE (083)
MARKING SCHEME
Time allowed: 3 Hours Maximum Marks: 70

SECTION-A (21 x1=21M)


1 True 1
(1 mark for correct answer)
2 a) KENDRIYA-vidyalaya@Sangathan 1
(1 mark for correct answer)
3 (b) False 1
(1 mark for correct answer)
4 @aaa 1
(1 mark for correct answer)
5 (b) (1,2,[1,3.5],3) 1
(1 mark for correct answer)
6 c. True@False 1
(1 mark for correct answer)
7 a.0 1
(1 mark for correct answer)
8 (d) Statements 2 and 4 1
(1 mark for correct answer)
9 True 1
(1 mark for correct answer)
10 b. del COLOR["Red"] 1
(1 mark for correct answer)
11 (c) file object 1
(1 mark for correct answer)
12 (iii) PYTHON#0#0 1
(1 mark for correct answer)
13 (b) describe 1
(1 mark for correct answer)
14 (c) Cardinality 1
(1 mark for correct answer)
15 d)DELETE FROM emp; 1
(1 mark for correct answer)
16 Alter Table 1
(1 mark for correct answer)
17 a. PAN 1
(1 mark for correct answer)
18 (a) VoIP 1
(1 mark for correct answer)
19 Modem 1
(1 mark for correct answer)
20 a. Both A and R are true and R is the correct explanation for A. 1
(1 mark for correct answer)
21 a. Both A and R are true and R is the correct explanation for A. 1
(1 mark for correct answer)
SECTION-B (7 x 2 =14M)

22 def Calc(a): #def 2


s=m=n=0 #local variable
for i in (0,a): #indentation and range function missing
if i%2==0:
s=s+I
elif i%5==0: #elif and colon
m=m+i
else:
n=n+i
print(s,m,n) #indentation
Calc(15)
(1/2 mark for each error)
23 i. def, for ( or any two examples) 2
ii. list , dictionary
(1 mark for each correct answer)
24 a del(D["Mumbai"]) or D.pop("Mumbai”) 2
b. print(S.split())
OR
L1.insert(1,100)
L1.sort()
(1 mark for each correct answer)
25 (a) 30 @ 2
MAX value of BEG and END are 2 and 4
(1 mark for each correct answer and 1 mark for maximum value)
26 Degree: The number of attributes or columns in a relation is called the Degree of the 2
relation.
Attribute: An attribute is a specification that defines a property of an object (column / fields
of a relation) Example: Any valid example to show degree and attribute.
(2 mark for correct answer)

Or
Foreign Key: Foreign Key is a non-key attribute derived from primary key of some other table.
A table can have 0 or more foreign keys.
(2 mark for correct answer)
27 DELETE is used for deleting records from a table. DROP is used to delete the entire schema of 2
any database object like table.
e.g. DELETE FROM STUDENT WHERE ROLL = 5;
DROP TABLE STUDENT;
(2 mark for correct answer)
Or
SUM() and AVG ()-which work only with numeric data
MAX(),MIN(),COUNT()-which work with numeric data and Non-Numeric Data
(2 mark for correct answer)
28 Star topology 2
In Star topology all the devices are connected to a central hub/node.
In Star topology if the central hub fails then the whole network fails.
Bus Topology
In Bus topology each device in the network is connected to a single cable which is known as
the backbone
In Bus topology the failure of the network cable will cause the whole network to fail.
(2 mark for correct answer)
Or
(i) POP3 -POST OFFICE PROTOCOL 3
URL -UNIFORM RESOURCE LOCATOR
(ii) Give one difference between XML and HTML.
HTML(Hyper Text Markup Language):
Hyper Text Markup Language (HTML) is a language which is used to design standardized Web
Pages, so that the Web contents can be read and under stood from any computer using web
browser.
Basic structure of every web page is designed using HTML. HTML uses tags to define the way
page content should be displayed by the web browser. Web pages are stored as .html or
.htm files.
Extensible Markup Language (XML): Extensible Markup Language is a markup language and
file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules
for encoding documents in a format that is both human-readable and machine-readable.
(1 mark for each correct answer)

SECTION-C (3 x 3 = 9 M)

29 def display_lines(): 3
fin = open('Poetry.txt','r')
count=0
lst=fin.readlines()
for line in lst:
l = line.strip().split()
if l[0]=='It':
count = count+1
print(count)
fin.close()
½ mark for opening file in correct mode
½ mark for readlines function
½ mark for loop
½ mark for strip and split function
½ mark for condition and increment
½ mark for display and close
Other working code is also allowed
Or
def Transfer (oldfile, newfile):
fin = open(oldfile, "r")
fout =open(newfile, "w")
while True:
text= fin.readline( )
if len(text) != 0:
if text[e] != "#":
fout.write(text)
fin.close()
fout.close()
Transfer("source.txt", "destination.txt")
(½ mark for correct function header)
(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
( ½ mark for checking condition)
(1 mark for correctly copying data from one file to another)
30 def Push_record(): # (1½ mark for correct push element) 3
for i in List:
if i[2]=="Delhi":
Record.append(i)
print(Record)
def Pop_record(): # (1½ mark for correct push element)
while True:
if len(Record)==0:
print('Empty Stack')
break
else:
print(Record.pop())

OR
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
def PushElement(S,N):
S.append(N)
def PopElement(S):
if S!=[ ]:
return S.pop()
else:
return None
ST=[]
for k in N:
if k%7==0:
PushElement(ST,k)
while True:
if ST!=[ ]:
print(PopElement(ST),end=" ")
else:
break
1- Mark for Push and 2-Mark for Pop functions.
31 (i)MCODE unique values (1 mark) 3
(ii) Degree = 4 (after removing one column) (1/2 mark)
Cardinality = 7 (after 2 more record added) (1/2 mark)
iii. mysql>alter table MOBILES add GST int; (1 mark)
OR
(i) mysql>update MOBILES set GST=(PRICE*0.18) (1 mark)
(ii) mysql>insert into MOBILES values(‘M06’,’iPHONE13’,’APPLE’,110000,’2022-03-01’);
(1 mark)
(iii) mysql>delete from MOBILES where MODEL=’NARZO50’; (1 mark)

SECTION-D (4 x 4 = 16 M)
32 I. TypeError exception raised when an operation or function is applied to an object of
inappropriate type,
ii.def get_numeric_input(prompt):
while True:
try:
value = float(input(prompt))
return value
except ValueError:
print("Error: Invalid input. Please Input a valid number.")
except:
print("Some Error Ocurred")

n1 = get_numeric_input("Input the first number: ")


n2 = get_numeric_input("Input the second number: ")
result = n1 * n2
print("Product of the said two numbers:", result)
(or any suitable code)
(3x 1 mark for each correct part – try, except, except)

OR
i.The raise keyword is used to manually raise an exception like exceptions are raised by
Python itself. That means, as a programmer can force an exception to occur through raise
keyword. It can also pass a custom message to your exception handling module.
ii.a = int( input("Enter value for a :"))
b = int( input("Enter value for b :"))
try:
if b == 0:
raise ZeroDivisionError # raising exception using raise keyword
print(a/b)
except ZeroDivisionError:
print("Please enter non-zero value for b.")
(or any suitable code)
(3x 1 mark for each correct part – try, except, except)

33 import csv #( ½ mark for import csv) 4


def SEARCH(): #(1 ½ mark for correct definition)
with open("empdata.csv",'r', newline='\r\n') as fh:
ereader=csv.reader(fh)
for r in ereader:
if int(r[2])>25000:
print(r[0],r[1],r[2],r[3])
break
else:
print("Employee Data not found")

def COUNTROW(): #(1 ½ for correct definition of function)


with open("empdata.csv ",'r', newline='\r\n') as fh:
sreader=csv.reader(fh)
count=0
for r in sreader:
count+=1
print("total record = ",count)
fh.close()
#main program (1/2 marks of functions calling)
SEARCH()
COUNTROW()
34 i. Select distinct Qty from garment; 4
ii. Select sum(Qty) from garment group by CCode having count(*)>1;
iii. Select GNAME, CNAME, RATE from garment g, cloth c where
g.ccode=c.ccode and Qty>100;
iv. Select avg(Rate) from garment where rate between 1200 and 2000;
(1 mark for each correct answer)
35 def ChecknDisplay():
import mysql.connector as mycon
mydb=mycon.connect(host="localhost",user="root",
passwd="school123",database="COMPANY")
mycur=mydb.cursor()
eid=input("Enter EmpID : ")
nm=input("Enter EmpName : ")
s=input("Enter Salary: ")
dept=input("Enter Department : ")
query="INSERT INTO EMPLOYEES VALUES ({},'{}',{},’{}’)"
query=query.format(eid,nm,s,dept)
mycur.execute(query)
mydb.commit()
mycur.execute("select * from EMPLOYEES where salary>50000")
for rec in mycur:
print(rec)
(½ 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)
SECTION-E (2 x 5 = 10 M)
36 i.Binary file: 5
Extension is .dat
Not human readable
Stores data in the form of 0s and 1s
CSV file
Extension is .csv
Human readable
Stores data like a text file
(1 mark for correct answer)
ii.import pickle
def AddStudents():
F= open("STUDENT.DAT",'wb') #1 statement to open the binary file to write data
while True:
Rno = int(input("Rno :"))
Name = input("Name : ")
Percent = float(input("Percent :"))
L = [Rno, Name, Percent]
c. pickle.dump(L,F)
Choice = input("enter more (y/n): ")
if Choice in "nN":
break
F.close()
(½ mark for opening in the file in right mode)
(½ mark for correctly inputting the data)
(½ mark for correctly writing the record in the file)
(½ mark for correctly closing the file, or ½ mark if the file was opened using with)
def GetStudents():
Total=0
Countrec=0
Countabove75=0
with open("STUDENT.DAT","rb") as F:
while True:
try:
R = pickle.load(F)
Countrec+=1
Total+=R[2]
if R[2] > 75:
print(R[1], " has percent =",R[2])
Countabove75+=1
except:
break
if Countabove75==0:
print("There is no student who has percentage more than 75")
F.close()
(½ mark for opening in the file in right mode)
(½ mark for correctly reading the data)
(½mark for checking condition in the file)
(½ mark for correctly closing the file)
37 a. Most suitable place to install the server is HR center, as this center has maximum number 5
of computers.
b.
.
c. Switch
d. Repeater may be placed when the distance between 2 buildings is more than 70 meter.
e. WAN, as the given distance is more than the range of LAN and MAN.
(1 mark for correct answer)

You might also like