0% found this document useful (0 votes)
31 views

Class 12-Special Computer Science PB-1

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Class 12-Special Computer Science PB-1

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

PRE-BOARD EXAMINATION I

2022-23

MAXIMUM MARKS: 70 TIME: 3.00 HOURS


CLASS: XII SUBJECT: COMPUTER SCIENCE

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
“Identifier can start with an underscore “

2. Which of the following can be used as valid variable identifier(s) in Python?


(a) 4thSum (b) Total (c) Number# (d) _Data

3 Given the following dictionary


dic1={‘aman’:85,’pahul’:98,’divya’:75}
print(sorted(dic1))
select the correct output:
a.[‘aman’, ‘divya’, ‘pahul’] b.[‘pahul’, ‘divya’, ‘aman’] c.[75,85,98] d.[‘aman’:85,’divya’:75,’pahul’:98]

4. Consider the given expression:


True or False and not 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


a = ‘Happy new year 2023’
a = a.split(‘e’)
print(a)
a. [‘Happy’ ,‘n’, ‘w’, ‘y’, ‘ar’ ,‘2023’] b. [‘Happy’ ,‘n w’, ‘y ar’ ,‘2023’]
c. [‘Happy n’, ‘w y’, ‘ar 2023’] d. [‘Happy’,’nw’,’yar’ ,‘2023’]
6 . Which of the following is not a file access mode
a. rb b. rb+ c. wb d rw

7. The command can be used to makes changes in the rows of a table in SQL.
a.Alter b.Modify c.Insert d.Update

8. Suggest the suitable command to remove the pre-existing database named Clients.
(a) delete database Clients (b) drop Clients (c) drop database Clients (d) Alter table drop Clients

9.Which of the following statement(s) would give an error after executing the following code?
STRING=”WELCOME “ #Statement 1
NOTE=” ” #Statement 2
for S in range[0,8]: #Statement 3
print (S) #Statement 4

10. Fill in the blank:


A column or a group of columns which can be used as the primary key of relation is called a
(a) Primary Key (b) Candidate Key (c) Alternate key (d) Foreign Key

11. Minimum argument required in seek function is


a. 0 b.1 c.2 d.3

12. Fill in the blank:


The columns of the table is called
(a)Attributes (b)Degree (c)Tuples (d)Cardinality

13 Fill in the blanks


Protocol is a set of
a. Formats b.Procedures c.Format and Procedures d.None of the mentioned

14. Evaluate the following expression and identify the correct


answer. x = 6 + 36/6 + 2*5
(a)45.0 (b)17.0 (c)26.25 (d)22.0

15.Which of the following clauses in SQL is most appropriate to use to select matching tuples in a
specific range of values ?
(a) IN (b) LIKE (c) BETWEEN (d) IS

16 returns the number of rows affected by the last execute method for the same cur
object a.count() b.rowcount() c.countrow() d.countall()

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):- The Global variable can be accessed inside or outside of the function
Reasoning (R):- A variable declared outside of the function or in global scope is known as global variable.
18. Assertion (A): Function blocks begin with the keyword def followed by the function name and parentheses (
( ) ).
Reason (R): In Function, a return statement with no arguments gives an error message

SECTION B

19. Gurjot has written a code to input a number and find a new number Reverse from Number with each of the
digits of Number in reversed order and display the content of Reverse on screen. His code is having errors. Re-
write the correct code and underline the corrections made.

Def REVERSAR(Number):
S=0
while Number<0:
S=S*10+Number/10
Number=Number//10
print(S)

20.What is secure Communication ? Differentiate between HTTP and HTTPS.

OR

How are tags used in XML different from tags in HTML? Write 2 points

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


myexam=”@@CBSE Examination 2022@@”
Write the output of: print(myexam[:5:])

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


my_dict = {‘empno’: 101, ‘name’: ‘Sonali’}
my_dict[‘name’] = ‘Nikhil’
my_dict[‘Gender’] = ‘M’
print(my_dict.items())

22. Differentiate between the Primary key and Alternate key of a table with the help of an example
23 (a) Write the full form of the following abbreviations:
(i) POP (ii) VoIP
(b) What is web hosting?
24. Predict the output of the Python code given below:
def Diff(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1

NUM= [8,20,1,4,3]
for CNT in range (4,0,-
1): A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),’*’, end=’ ‘)

OR
Predict the output of the Python code given below:
tuple1 = (6, 8, 32, 66, 3 ,6)
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)

25 While using SQL pattern matching, what is the difference between ‘_’(underscore) and ‘%’ wildcard sym-
bols?
OR
Categorize the following commands as DDL or DML:
DROP TABLE, INSERT, ALTER, DELETE
SECTION C

26(a) Consider the following tables – Salesperson and item


TABLE : SALESPERSON
Code SALARY ITCODE
1001 60000 I2
1002 70000 I5
1004 55000 I7
TABLE : ITEM
ITCODE ITEMTYPE
I2 STATIONARY
I5 HOSIERY
I7 BAKERY

What will be the output of the following statement?


SELECT * FROM Salesperson NATURAL JOIN ITEM;

(b) Consider the following table:


Table:SchoolBus
Rtno area_covered capacity noofstudents distance Transporter charges
1 Vasant Kunj 100 120 10 Shivam Travel 100000
2 Hauz Khas 80 80 10 Anand Travel 95000
3 Pitampura 60 55 30 Anand Travel 60000
4 Rohini 100 90 35 Shivam Travel 75000
5 Yamuna Vihar 50 60 45 Anand Travel 55000
6 Krishna Nagar 70 80 30 Yadav Co. 80000
7 Vasundhara 80 110 20 Yadav Co. 100000
8 Paschim Vihar 100 40 20 Speed Travels 55000
9 Saket 120 120 10 Speed Travels 100000
10 Janak Puri 100 100 20 Kisan Tours 95000

Give the output


(a) Select sum(distance) from schoolbus where transporter=”Yadav Co.”
(b) Select min(noofstudents) from schoolbus
(c) Select avg(charges) from schoolbus where transporter=”Anand Travels”
(d) Select distinct transporter from schoolBus.

27 Write a method in python to read lines from a text file INDIA.TXT, to find and display the occurrence of
the word “India”.

For example: If the content of the file is

“India is the fastest growing economy. India is look-


ing for more investments around the globe. The whole world is looking at India as a great market. Most of the
Indians can foresee the heights that India is capable of reaching.”

The output should be 4


OR
Write a method/function DISPLAYWORDS() in python to read lines from a text file STORY.TXT, and display
those words, which are less than 4 characters.

28(a). Consider the following tables EMPLOYEES and EMPSALARY. Write SQL outputs for SQL queries
(i) to (iv).

EMPLOYEES
EMPID FIRSTNAME LASTNAME ADDRESS CITY
010 George Smith 83 First Street Howard
105 Mary Jones 842 Vine Ave. Losantiville
152 Sam Tones 33 Elm St. Paris
215 Sarah Ackerman 440 U.S. 110 Upton
244 Manila Sengupta 24 Friends Street New Delhi
300 Robert Samuel 9 Fifth Cross Washington
335 Henry Williams 12 Moore Street Boston
400 Rachel Lee 121 Harrison St. New York
441 Peter Thompson 11 Red Road Paris

EMPSALARY
EMPID SALARY BENEFITS DESIGNATION
010 75000 15000 Manager
105 65000 15000 Manager
152 80000 25000 Director
215 75000 12500 Manager
244 50000 12000 Clerk
300 45000 10000 Clerk
335 40000 10000 Clerk
400 32000 7500 Salesman
441 28000 7500 Salesman

(i) SELECT FIRSTNAME, SALARY FROM EMPLOYEES, EMPSALARY WHERE DESIGNATION


=‘Salesman’ AND EMPLOYEES.EMPID=EMPSALARY.EMPID;
(ii) SELECT COUNT (DISTINCT DESIGNATION)FROM EMPSALARY;
(iii) SELECT DESIGNATION, SUM(SALARY) FROM EMPSALARY GROUP BY DESIGNATION
HAV- ING COUNT (*)>2;
(iv) SELECT SUM (BENEFITS) FROM EMPLOYEES WHERE DESIGNATION = ’Clerk’;:

(b) Write the command to view all the databases.

29 Write definition of a Method AFIND(CITIES) to display all the city names from a list of CITIES, which are
starting with alphabet A.

For example:
If the list CITIES contains

[“AHMEDABAD”,”CHENNAI”,”NEW DELHI”,”AMRITSAR”,”AGRA”]

The following should get displayed


AHEMDABAD
AMRITSAR
AGRA

30. Write a function in Python POP(Arr), where Arr is a stack implemented by a list of numbers. The
function returns the value deleted from the stack.
OR

Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list push all numbers
divisible by 5 into a stack implemented by using a list. Display the stack if it has at least one element,
otherwise display appropriate error message.

SECTION D
31. BeHappy Corporation has set up its new centre at Noida, Uttar Pradesh for its office and web-based
activi- ties. It has 4 blocks of buildings.

Distance between the various blocks is as follows:

A to B 40 m
B to C 120m
C to D 100m
A to D 170m
B to D 150m
A to C 70m

Numbers of computers in each block


Block A - 25
Block B - 50
Block C - 125
Block D - 10

(a) Suggest and draw the cable layout to efficiently connect various blocks of buildings within the Noida
centre for connecting the digital devices.
(b) Suggest the placement of the following device with justification
i. Repeater ii. Hub/Switch
(c) Which kind of network (PAN/LAN/WAN) will be formed if the Noida office is connected to its head
office in Mumbai?
(d) Which fast and very effective wireless transmission medium should preferably be used to connect the
head office at Mumbai with the centre at Noida

32. (a) Write the output of the code given below:


p=5
def sum(q,r=2):
global p
p=r-q*2
print(p, end=’#’)
a=20
b=5
sum(a,b)
sum(r=5,q=10)

(b)Write Python code for the following:

(i) To create a MySQL connection named db for localhost, with username = “teacher” and password =
“my- class”

(ii) To create a database cursor named as dbcrsr.


(iii) To open a database named “CLASS” using the above declared database cursor dbcrsr.
(iv) To add a new record into the table “STUDENT” in the above connected database “CLASS” with details
for the attributes (SNo, SName, Marks) as (“S102”, “Tanya”, 92.5)
OR
(a) Find and write the output of the following Python code :

Str1=”EXAM2018”
Str2=””
I=0
while I<len(Str1):
if Str1[I]>=”A” and Str1[I]<=”M”:
Str2=Str2+Str1[I+1]
elif Str1[I]>=”0” and Str1[I]<=”9”:
Str2=Str2+ (Str1[I-1])
else:
Str2=Str2+”*”
I=I+1
print (Str2)
(b) A resultset is extracted from the database using the cursor object (that has been already created) by
giving the following statement.

Mydata=cursor.fetchone()

(i) How many records will be returned by fetchone() method?


(ii) What will be the datatype of Mydata object after the given command is executed?

33. What is Delimiters in CSV files?


Write a function display () in python to display all the students who have got a distinction(scored percentage
more than or equal to 75) from a csv file “stud.csv”, assuming the csv file is containing the following fields:
roll,name,percentage
OR
Write a Program in Python that defines and calls the following user defined functions:
(i) add() – To accept and add data of EMPLOYEE to a CSV file ‘emp.csv’. Each record consists of a list with
field elements as empid, ename and esalary to store employee id, employee name and employee salary
respec- tively.
(ii) search()- To display the records of the employee whose salary is more than 10000.

SECTION E

34 Consider the table, MOVIEDETAILS given


below:

Table: MOVIEDETAILS

MOVIEID TITLE LANGUAGE RATING PLATFORM


M001 Minari Korean 5 Netflix
M004 MGR Magan Tamil 4 Hotstar
M010 Kaagaz Hindi 3 Zee5
M011 Harry Potter and the Chamber of Secrets English 4 Prime Video
M015 Uri Hindi 5 Zee5
M020 Avengers: Endgame English 4 Hotstar

a) Identify the degree and cardinality of the table.


b) Which field should be made the primary key? Justify your answer.
c) Identify the candidate key(s) from the table MOVIEDETAILS.
d) Consider the table SCHEDULE given below:

Table: SCHEDULE
SLOTID MOVIEID TIMESLOT
S001 M010 10 AM to 12 PM
S002 M020 2 PM to 5 PM
S003 M010 6 PM to 8 PM
S004 M011 9 PM to 11 PM

Which field will be considered as the foreign key if the tables MOVIEDETAILS and SCHEDULE are related in
a database?

35.Amritya Seth is a programmer, who has recently been given a task to write a python code to perform the
fol- lowing binary file operations with the help of two user defined functions/modules:

a. AddStudents() to create a binary file called STUDENT.DAT containing student information – roll
number, name and marks (out of 100) of each student.
b. GetStudents() 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. The
function should also display the average percent. He has succeeded in writing partial code and has missed out
certain statements, so he has left certain queries in comment lines.

You as an expert of Python have to provide the missing statements and other related queries based on the fol-
lowing code of Amritya.

Answer any four questions (out of five) from the below mentioned questions.

import pickle
def AddStudents():
#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]
#2 statement to write the list L into the file
Choice = input(“enter more (y/n): “)
if Choice in “nN”:
break
F.close()

def GetStudents():
Total=0
Countrec=0
Countabove75=0
with open(“STUDENT.DAT”,”rb”) as F:
while True:
try:
#3 statement to read from the
file 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”)
average=Total/Countrec
print(“average percent of class = “,average)
AddStudents()
GetStudents()

i. Which of the following commands is used to open the file “STUDENT.DAT” for writing only in binary
for- mat? (marked as #1 in the Python code)
a. F= open(“STUDENT.DAT”,’wb’) b. F= open(“STUDENT.DAT”,’w’)
c. F= open(“STUDENT.DAT”,’wb+’) d. F= open(“STUDENT.DAT”,’w+’)

ii. Which of the following commands is used to write the list L into the binary file, STUDENT.DAT? (marked
as #2 in the Python code)
a. pickle.write(L,f) b. pickle.write(f, L) c. pickle.dump(L,F) d. f=pickle.dump(L)

iii. Which of the following commands is used to read each record from the binary file
STUDENT.DAT? (marked as #3 in the Python code)
a. R = pickle.load(F) b. pickle.read(r,f) c. r= pickle.read(f) d. pickle.load(r,f)

iv. Which of the following statement(s) are correct regarding the file access modes?
a. ‘r+’ opens a file for both reading and writing. File object points to its beginning.
b. ‘w+’ opens a file for both writing and reading. Adds at the end of the existing file if it exists and creates a new
one if it does not exist.
c. ‘wb’ opens a file for reading and writing in binary format. Overwrites the file if it exists and creates a new one
if it does not exist.
d. ‘a’ opens a file for appending. The file pointer is at the start of the file if the file exists.

v. Which of the following statements correctly explain the function of seek() method?
a. tells the current position within the file.
b. determines if you can move the file position or not.
c. indicates that the next read or write occurs from that position in a file.
d. moves the current file position to a given specified position.

You might also like