0% found this document useful (0 votes)
34 views12 pages

Puterscience Class-XII CPBE-2023

Uploaded by

bvcbsecslab
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)
34 views12 pages

Puterscience Class-XII CPBE-2023

Uploaded by

bvcbsecslab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

COMMON PRE-BOARD EXAMINATION 2022-23

Subject: COMPUTER SCIENCE (083)

Time Allowed: 3 Hours Maximum Marks: 70


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 c only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1. State True or False: 1
“All keywords in Python are in lowercase.”

2. Identify the invalid identifier. 1


a) keyword
b) token
c) operator
d) and

3. Consider the following Dictionary: 1


D = {1: ['Amit',23,21], 2: ['Suman',45,34], 3: 'Ravi', 4: 'Anuj'}
m = D.get(2)
print(m[2])
Write the output of the given code:
a) 34
b) 45
c) m
d) Suman
4. Consider the given expression: 1
12%4+6+4//3
Which of the following will be correct output if the given expression is evaluated?
a) 7.0
b) 7.33
c) 7
d) 7.03

Page 1 of 12
5. Select the correct output of the code: 1
>>> s="i love my country"
>>> r = "i love my class"
>>> s[2:6] + r[-7:]

a) 'loveyclass'
b) 'lovey class'
c) 'loveclass'
d) 'love class'
6. Which function is used to write data in binary mode? 1
a) write
b) writelines
c) pickle
d) dump
7. Fill in the blank: 1
Duplication of a record is called ___________.
a) Redundancy
b) Inconsistency
c) Discrepancy
d) Integrity

8. The query to add a column ‘DOB’ of data type ‘DATE in table STUDENT. 1
a) ALTER STUDENT TABLE ADD DOB DATE;
b) ALTER TABLE STUDENT MODIFY DOB DATE;
c) ALTER TABLE STUDENT ADD DOB DATE;
d) ALTER STUDENT TABLE MODIFY DOB DATE;

9. Consider the following code: 1


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
Which of the following statement(s) would give an error after executing the following code?
a) Statement 1
b) Statement 2
c) Statement 3
d) Statement 4

10. Fill in the blank: 1


_________ is a table constraint in SQL that will prevent the entry of duplicate rows.
a) NULL
b) Primary Key
c) Check
d) Distinct

Page 2 of 12
11. Write the output of the following code: 1
f= open("data.txt", "w")
L=["My\n", "name\n", "is\n", "Amit"]
f.writelines(L)
f.close( )
f= open("data.txt","r")
print(len (f.readline()))

a) 2
b) 4
c) 3
d) 5
12. Fill in the blank: 1
The command used to change the data in a SQL table is ___________.
a. UPDATE
b. MODIFY
c. ALTER
d. CHANGE
13. Fill in the blank: 1
In __________topology failure in the central networking device may lead to the failure of
complete network.
a) Bus
b) Star
c) Ring
d) Tree

14. Evaluate the following expression and identify the correct answer. 1
not True and not False or not True
a. False
b. NONE
c. NULL
d. True

15. Give the output of : SELECT MOD(40, 15.5); 1


a. 40
b. 15.5
c. 9.0
d. Error
16. In context of Python - Database Connectivity, the function fetchone() is a method of which 1
object?
a) connection
b) database
c) cursor
d) query

Page 3 of 12
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): Function can take input values as parameters, execute them and return the 1
output (if required) to the calling function with a return statement.
Reason (R): A function in Python can return multiple values.
18. Assertion (A): Pickle in Python is primarily used in serializing and deserializing a Python object 1
structure.
Reason (R): pickle.dump() method is used to read the object in file and pickle.load() method is
used to write the object from pickled file.

SECTION B

19. Raju has written a function to check the largest of two numbers. There are errors in his code. 2
Rewrite the correct code and underline the corrections made.
def larg()
a = int(Input("Enter any number"))
b = int(input("Enter any number"))
if a=>b:
print("First number is greater')
else:
print("Second number is greater")
20. Write any two advantages and disadvantages of Twisted Pair Cables. 2
OR
Write any two advantages and disadvantages of Bus Topology.

21. a. Given is a Python String declaration: 1


exam="CBSE Examination 2023"
Write the output of: print(exam[ - 1 0 : - 2 : 2 ])

b. Write the output of the code given below: 1


A = {1: "One", 2: "Two", 3: "Three", 4:"Four"}
B = {1: 'Amit', 2: 'Sunil', 5: 'Lata', 6: 'Suman'}
A.update (B)
print(A)
22. Give a suitable example of a SQL table with sample data and illustrate Primary and Candidate 2
Keys in it.
23. a. Give the full forms of the following: 2
(i) FTP (ii) HTTPS

b. Define VoIP.

Page 4 of 12
24. Predict the output of the Python code given below: 2
def changer(str, s):
nwstr=' '
for x in str:
if x.isdigit():
nwstr=nwstr + s
elif x.isalpha():
if x.isupper():
nwstr=nwstr+x.lower()
else:
nwstr=nwstr+x.upper()
else:
nwstr=nwstr + '*'
return(nwstr)
print(changer('Exam 2023' , '#' ) )
OR

Predict the output of the Python code given below:


def ChangeVal(M,N):
for i in range(N):
if M[i]%4 == 0:
M[i]//=4
if M[i]%6 == 0:
M[i]//=6
L = [35,80,45,22]
ChangeVal(L,4)
for i in L:
print(i,end="-#")
25. Differentiate between the NOW( ) and SYSDATE( ) functions in SQL with an example. 2

OR

Categorize the following commands as DDL or DML:


DROP, INSERT, ALTER, DELETE

SECTION C
26. a. Consider the following tables – SALESPERSON and ITEM: 1+2

Page 5 of 12
What will be the output of the following statement?
SELECT * FROM SALESPERSON NATURAL JOIN ITEM;

b. Write the output of the queries (i) to (iv) based on the table PAY given below:
Table: PAY
No Name Salary Area Age Grade Dept
1 Krippe 40000 West 45 C Civil
2 Ravina 35000 South 38 A Elec
3 Karan 60000 North 52 B Comp
4 Tarun 142000 East 29 A Civil
5 Aryan 50000 West 30 A Elec

i. SELECT * FROM PAY WHERE AGE>=45;


ii. SELECT NAME, AGE FROM PAY ORDER BY AGE DESC;
iii. SELECT NAME, DEPT FROM PAY WHERE NAME LIKE '%i%';
iv. SELECT NAME, SALARY FROM PAY WHERE SALARY BETWEEN 40000 AND 50000;

27. Write a method Countvowels( ) in Python to read the Text File ‘Attitude.Txt’ and display the 3
number of uppercase vowels in the file.
Example: If the file content is as follows:
All Birds Find Shelter During A Rain.
But An Eagle Avoids Rain By Flying Above The Clouds.
Problems Are Common, But Attitude Makes The Difference.

The Countvowels( ) function should display the output as:


Number of Vowels: 8
OR

Write a function Countchars( ) in Python, which should read each character of a Text File
“Character.Txt” and display the count of words starting with letter ' I ' (including both the
cases).
Example: If the file content is as follows:
Intelligence plus character - that is the goal of true education
Develop your character so that you are a person of integrity.
The Countchars( ) function should display the output as:
No. of Words Starting with letter I: 3
28. a. Write the outputs of the SQL queries (i) to (iv) based on the relations DEPT and WORKER 3
given below:
Page 6 of 12
i. SELECT GENDER, COUNT(GENDER) AS 'GENDER COUNT' FROM WORKER GROUP BY GENDER;
ii. SELECT DISTINCT CITY FROM DEPT;
iii. SELECT NAME, DOB FROM WORKER W, DEPT D WHERE W.DCODE=D.DCODE AND
GENDER='FEMALE';
iv. SELECT MIN(DOJ), MAX(DOB) FROM WORKER;

b. Write the SQL command to view all the tables in a database.

29. Write a function ZeroEnding(SCORE) that returns the sum of all the values in the List of SCORES 3
which are ending with the number zero(0).
For example:
If the SCORE contain [200, 456, 300, 100, 234, 678]
The sum should be displayed as 600

30. John has created a Dictionary containing name and price as key value pairs, of 5 items in an 3
Instrument Box.
Write a program, using User Defined Functions to perform the following operations:
 Push the keys (name of the item) of the Dictionary into a Stack, where the corresponding
value (price) is less than 45.
 Pop and display the content of the Stack.
For example:
If the sample content of the dictionary is as follows:
Items = { " Compass " : 65, " Divider ":60, " Protractor ":45, " Set Squares ":40,
" Eraser ":30, " Ruler ":32}
The output from the program should be:
Ruler
Eraser
Set Squares
Empty Stack
OR
Page 7 of 12
Hanna has a List containing 5 CITIES. You need to help her to create a program with separate
User Defined Functions to perform the following operations based on the List.
 Traverse the content of the List and push the CITIES, which are starting with alphabet A
into a Stack.
 Pop and display the content of the Stack.
For Example:
If the List CITIES contains:
["AHMEDABAD", "CHENNAI", "NEWDELHI", "AMRITSAR", "AGRA"]
The following should get displayed:
AGRA
AMRITSAR
AHMEDABAD
Stack Empty

SECTION D

31. Adams Corporation has head office in Mumbai is planning to set up its new centre at Noida,
Uttar Pradesh for its office and web-based activities. It has 4 blocks of buildings.

Distance between various blocks:


Block Distance
A to B 40 m
B to C 120 m
C to D 100 m
A to D 170 m
B to D 150 m
A to C 70 m
Number of computers in each block:
Block Number of Computers
Block A 25
Block B 50
Block C 125
Block D 10

i. Suggest and draw the cable layout(s) to efficiently connect various blocks of buildings 1
within the Noida centre for connecting the digital devices.

Page 8 of 12
ii. Suggest the placement of the following device with justification. 1
(a) Repeater
(b) Hub/Switch

iii. Which kind of network (PAN/LAN/WAN) will be formed if the Noida office is connected 1
to its head office in Mumbai?
iv. Which of the following will you suggest to establish the online face-to-face 1
communication between the people in the head office at Mumbai with the people at
Noida?
a. Cable TV
b. Video Conferencing
c. E-mail
d. Text Chat
v. Which fast and very effective wireless transmission medium should preferably be used 1
to connect the head office at Mumbai with the centre at Noida?

32. a. Write the output of the code given below: 2+3


p, q=8, [8]
def sum(r, s=5):
p=r+s
q=[r, s]
print(p, q, sep='@')
sum(3,4)
print(p, q, sep='@')

b. The School is managing student data in ‘Student’ table in ‘School’ database. The code given
below connects to database School and retrieves all records and display total number of
students. The structure of a record of the table Student is:
RollNo – integer; Name – string; Class – integer; Marks – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is ‘root’, Password is ‘abc’.
• The table exists in a MYSQL database named ‘School’.
Write the following missing statements to complete the code:

import mysql.connector as mysql


def sql_data( ):
conn=mysql.connect(host="localhost", user="root", password="abc", database="school")
────────────── #Statement 1
cursor.execute("Select * from Student")
─────────────── #Statement 2
Count=0
for x in Records:
Count+=1
Print(“Number of records:”, Count)
─────────────── #Statement 3

Page 9 of 12
Statement 1 – To create the cursor object.
Statement 2 – To fetches all the rows in the result set.
Statement 3 – To close the connection.
OR
a. Predict the output of the code given below:
s="Rs.12"
n, m = len(s), " "
for i in range(0, n):
if s[i].islower():
m = m +s[i]
elif s[i].isupper():
m = m +s[i+1]
elif s[i].isdigit():
m = m*int(s[i])
else:
m = '@'+m
print(m)

b. The code given below reads records from the table named Vehicle and displays only those
records which have model 2010. The structure of a record of table Vehicle is:
V_ID – integer; Name – string; Model – integer; Price – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is ‘root’
• Password is ‘abc’
• The table exists in a MYSQL database named ‘Transport’.
Write the following missing statements to complete the code:
Statement 1 – To make a connection to the database
Statement 2 – The query that extracts records of those vehicles whose model is 2010.
Statement 3 – To fetch single record from the results set

import mysql.connector as mysql


def display():
────────────── #Statement 1
cursor=conn.cursor( )
────────────── #Statement 2
cursor.execute(querry)
────────────── #Statement 3
print(row)
conn.close( )

33. What is the significance of newline argument in open( ) function of CSV file? 5
Write a program in Python that defines and calls the following User Defined Functions:

Page 10 of 12
i. ADD( ) – To accept and add data of a Employee to a CSV file ‘Emp.csv’. Each record
consists of a list with field elements as Empid, Empname and Salary to store Employee
id, Employee name and Employee salary respectively.
ii. DISPLAY( ) – To display all the records present in the CSV file named ‘Emp.csv’.
OR
What is the function of csv.reader object?
Write a Program in Python that defines and calls the following User Defined Functions:
i. ADD( ) – To accept and add data of furniture to a CSV file ‘furdata.csv’. Each record
consists of a list with field elements as fid, fname and fprice to store furniture id,
furniture name and furniture price respectively.
ii. SEARCH( ) – To display the records of the furniture whose price is more than 10000.

SECTION E
34. Rubina creates a table SUPPLIER with a set of records to maintain the product details. After 1+1+2
creation of the table, she has entered data of 5 product details in the table.
Table:SUPPLIER
SNo PName CName Qty Price City
S1 Bread Britannia 150 8.00 Delhi
S2 Cake Britannia 250 20.00 Mumbai
S3 Coffee Nescafe 170 45.00 Delhi
S4 Chocolate Amul 350 10.00 Mumbai
S5 Sauce Maggi 300 36.00 Jaipur

Based on the data given above answer the following questions:


i. Name the most appropriate columns, which can be considered as Candidate Keys.
ii. If a column City has been removed and three more products are added to the table
then how these changes will affect the Degree and Cardinality of the above given table.
iii. Write the statements to:
a. Write the SQL command to create the above table with suitable datatype and
Primary Key constraints for SNo field and NOT NULL constraints for PName field.
b. Increase the price of the product by 10 whose quantity is more than 250.
OR
(Option for part iii only)

iii. Write the statements to:


a. Remove the record of the Product whose City is Jaipur.
b. Add another column DOE of type Date in the Supplier table.

Page 11 of 12
35. Consider Students data Sid, Sname and Fee. George wrote Python function to create binary file
‘std.dat’ and store their records. He now has to read and display all the records in to the file
‘std.dat’.
As a Python expert, help him to complete the following code based on the requirement given
below.

___________ # STATEMENT 1
def add_record():
f = open('std.dat','ab')
Sid =int(input('Student code:'))
Sname = input('Student Name:')
Fee = int(input('Fees:'))
d = [Sid, Sname, Fee]
____________ # STATEMENT 2
f.close()
def search():
______________ # STATEMENT 3
while True:
try:
___________ # STATEMENT 4
print(d)
except EOFError:
break
f.close()

i. Name the module to be imported in the program (STATEMENT 1). 1


ii. Which statement should Adams fill in STATEMENT 2 to append the data in the file, 1
‘std.dat’?
iii. Write the correct statement required to open the file ‘std.dat’ in read mode in 2
STATEMENT 3 and in STATEMENT 4 to read the data from the same file.

Page 12 of 12

You might also like