Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views15 pages

12 Computer SP 11

The pdf is about computer programs

Uploaded by

komalchahal079
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views15 pages

12 Computer SP 11

The pdf is about computer programs

Uploaded by

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

Do not start attempting the paper until you are asked to do so

MANU VATIKA SR. SEC. SCHOOL, BUDHLADA


PREBOARD EXAMINATION: 2022-23

Maximum Marks : 70
Time Duration : 3Hr
Subject : Computer
Science
B
General Instructions:
1. This question paper contains five sections, from 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.
8. All programming questions are to be answered using Python Language only.

Section A
1. State true or false:
The max() and min() when used with tuples, can work if elements of the tuple are all of the same types.
a) True
b) False
2. Which of the following join gives the intersection of two tables?
a) Inner join
b) Outer join
c) Equi join
d) None of these
3. Which command is used to display the name of existing databases?
a) show databases;
b) display databases;
c) result databases;
d) output databases;
4. What is the area of memory called, which stores the parameters and local variables of a function call?
a) an array
b) storage area
c) a stack
d) a heap
5. Signals generated by an operating system to send it over phone line must be further converted into a/an
a) analog signal
b) microwave
c) AC signal
d) digital signal
6. To open a file c:\res.txt for reading, we can use (select all correct options):
a. file = open("c: \res.txt", "r")
b. file = open("c:\ \res.txt", "r")
c. file = open(r"c: \res.txt", "r")
d. file = open(file = "c:\res.txt", "r")
e. file = open(file = "c:\ \res.txt", "r")
f. file = open("c:\ \res.txt")
1 / 15
a) d, e, f
b) a, e, f
c) b, d, f
d) b, c, f
7. What does the special file called data dictionary contains?
a) The data types of all data in all files.
b) The names of all fields in all files.
c) All of these
d) The widths of all fields in all files.
8. Which SQL function is used to count the number of rows in a SQL query?
a) COUNT(*)
b) NUMBER( )
c) COUNT( )
d) SUM( )
9. A can get input from live interaction through keyboard/GUI or it may take input as command line arguments
or from the files.
a) Code
b) Program
c) Class
d) Method
10. Which of the following functions removes all leading and trailing spaces from a string?
a) rstrip()
b) lstrip()
c) strip()
d) all of these
11. What is the conventional name of pointer associated with the stack?
a) FIRST
b) TOP
c) REAR
d) FRONT
12. Which shortcut key is used to pause the function?
a) Alt + Break
b) Insert + Break
c) Ctrl + Break
d) Shift + Break
13. Which of the following is a client-side scripting language?
a) Perl
b) PHP
c) VB Script
d) Ruby
14. Which of the following is a relational operator?
a) <<
b) <
c) =
d) /=
15. Find ODD parity bit for 10010110
a) 0
b) 1
c) none of these

2 / 15
d) 2
16. Two devices are in network if
a) a process is running on both devices
b) a process in one device is able to exchange information with a process in another device
c) PIDs of the processes running of different devices are of same type
d) none of these
17. Assertion (A): The list can contain data of different types.
Reason (R): We can use slice [:] operator to access the data of the list.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
18. Assertion (A): It is good practice to close the file once all the operations are done.
Reason (R): We can perform any operation on the file externally using the file system which is currently opened in
Python.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
Section B
19. What measures do wireless networks employ to avoid collisions?
20. What is the output of the following?
i=4
while True:
if i% 0o7 == 0:
break
print(i, end = ' ')
i += 1
OR
Predict the output of following code fragment:
fruit = { }
f1 = ['Apple', 'Banana', 'apple', 'Banana']
for index in f1:
if index in fruit:
fruit [index] += 1
else:
fruit[index] =1
print(fruit)
print (len(fruit))
21. Write Python code to increase age of all employees by 1 year in the Employee table of database HTMdb with
userid HRMan and password HRMANexe@pwd.
22. Answer:
i. What will the following query do?
import mysql.connector
db = mysql.connector.connect(.. )
cursor = db.cursor( )
db.execute("SELECT * FROM staff WHERE person_id in {}".format((1,3,4)))
db.commit( )
db.close( )
3 / 15
ii. What does connection.commit( ) method do?

23. What will following function print when called?


def addEm (x, y, z):
return x + y + z
print x + y + z
24. Why is following code giving errors?
name = "Rehman"
print("Greetings !!!")
print("Hello", name)
print("How do you do?")
OR
What is the advantage of pop() method over a del keyword?
25. Write a method in Python to write multiple line of text contents into a text file diary.txt.
OR
Write a function in Python that counts the number of "Me" or “My" words present in a text file "STORY.TXT". If the
“STORY.TXT" contents are as follows:
My first book
was Me and
My Family. It
gave me
chance to be
Known to the
world.
The output of the function should be:
Count of Me/My in file:
Section C
26. Answer:
i. Rewrite the following code into for loop:
i = 3
while (i < 5):
if (i == 4):
print("Welcome")
else:
print("No entry")
i = i + 1
print("value of i", i)

ii. Find the output of the given code.


list1 = ['P', 'R', 'O', 'G', 'R', 'A', 'M']
for i in range(len(list1)) :
print(list1[i])

27. Mr. Mittal is using a table with following columns


: Name, Class, Streamed, Stream_name
He needs to display names of students who have not been assigned any stream or have been
assigned stream_name that ends with "computers
He wrote the following command, which did not give the desired result.
SELECT Name, Class FROM Students
WHERE Stream_name = NULL OR Stream_name = “%computers” ;
Help Mr. Mittal to run the query by removing the error and write correct query.
4 / 15
OR
You want to group the result set based on some column's value. Also, you want that the grouped result should appear in a
sorted order. In which order will you write the two clauses (for sorting and for grouping). Give example to support your
answer.
28. Write definition of a method OddSum(NUMBERS) to add those values in the list of NUMBERS, which are not even.
29. A binary file “STUDENT.DAT" has structure(admission_number, Name, Percentage). Write a function countrec() in
Python that would read contents of the file "STUDENT.DAT" and display the details of those students whose
percentage is above 75. Also display number of students scoring above 75%.
30. Write a function that takes a number n and then returns a randomly generated number having exactly n digits (not
starting with zero) e.g., if n is 2 then the function can randomly return a number 10-99 but 07, 02, etc., are not valid two-
digit numbers.
OR
What is the utility of:
i. default arguments
ii. keyword arguments
Section D
31. Write Addnew(Book) and Remove(Book) methods in Python to Add a new Book and Remove a Book from a List
of Books, considering them to act as PUSH and POP operations of the data structure stack.
32. Answer (i) & (ii) OR (iii) & (iv)
i. Differentiate between a Text File and a Binary file.
ii. A text file "Quotes.Txt" has the following data written in it :
Living a life you can be proud of Doing you
Spending your time with people and activities that are important to you
Standing up for things that are right even when it's hard
Becoming the best version of you
Write a user defined function to display the total number of words present in the file.
iii. Write a function to read the content of a text file "DELHI.txt" and display all those lines on screen, which are
either starting with 'D' or 'M'.
iv. Given a pickled file-log.dat, containing a list of strings. Write a python function that reads the file and looks for a
line of the form Error: 0.2395 whenever such line is encountered, extract the floating-point value and compute
the total of these error values. When you reach the end of file print total number of such error lines and an
average of an error value.
33. Consider the following tables ACTIVITY and COACH. Write SQL commands for the following statements
Table: ACTIVITY
Acode ActivityName Stadium ParticipantsNum PrizeMoney ScheduleDate
1001 Relay 100 × 4 Star Annex 16 10000 23-Jan-04
1002 High jump Star Annex 10 12000 12-Dec-03
1003 Shot Put Super Power 12 8000 14-Feb-04
1005 Long Jump Star Annex 12 9000 01-Jan-04
1008 Discuss Throw Super Power 10 15000 19-Mar-04

Table: COACH

Pcode Name Acode


1 Ahmad Hussain 1001
2 Ravinder 1008
3 Janila 1001
4 Naaz 1003
5 / 15
i. To display the names of all activities with their Acodes in descending order.
ii. To display sum of PrizeMoney for the Activities played in each of the Stadium separately.
iii. To display the coach's names and Acodes in ascending order of Acode from the table COACH.
iv. To display the content of all activities for which ScheduleDate is earlier than 01-01-2004 in ascending order
of ParticipantsNum.
OR

Consider the following tables CARDEN and CUSTOMER and answer (b) and (c) parts of this question:

Table: CARDEN

Ccode CarName Make Colour Capacity Charges


501 A-Star Suzuki RED 3 14
503 Indigo Tata SILVER 3 12
502 Innova Toyota WHITE 7 15
509 SX4 Suzuki SILVER 4 14
510 C Class Mercedes RED 4 35

Table: CUSTOMER

Code Cname Ccode


1001 Hemant Sahu 501
1002 Raj Lai 509
1003 Feroza Shah 503
1004 Ketan Dhal 502
a. Give a suitable example of a table with sample data and illustrate Primary and Alternate Keys in it.
b. Write SQL commands for the following statements:
a. To display the names of all the silver-colored cars.
b. To display names of car, make and capacity of cars in descending order of their sitting capacity.
c. To display the highest charges at which a vehicle can be hired from CARDEN.
d. To display the customer name and the corresponding name of the cars hired by them.
c. Give the output of the following SQL queries:
i. SELECT COUNT(DISTINCT Make)FROM CARDEN;
ii. SELECT MAX(Charges), MIN(Charges) FROM CARDEN;
iii. SELECT COUNT(*), Make FROM CARDEN;
iv. SELECT CarName FROM CARDEN WHERE Capacity=4;

Section E
34. Read the text carefully and answer the questions:
The Freshminds University of India is starting its first campus in Ana Nagar of South India with its center admission
office in Kolkata. The university has 3 major blocks comprising of Office Block, Science Block and Commerce Block in
the 5 km area Campus.

As a network expert, you need to suggest the network plan as per (i) to (iv) to the authorities keeping in mind the
6 / 15
distance and other given parameters.
Expected Wire distances between various locations:
Office Block to Science Block 90 m
Office Block to Commerce Block 80 m
Science Block to Commerce Block 15 m
Kolkata Admission office to Ana Nagar Campus 2450 km
Expected number of Computers to be installed at various locations in the University are as follows:
Office Block 10
Science Block 140
Commerce Block 30
Kolkata Admission office 8
i. What type of server should be installed in university?
i. Dedicated
ii. Non-dedicated
ii. Suggest the most suitable place (i.e., block) to house the server of this university with a suitable reason.
iii. Suggest the most suitable (very high speed) service to provide data connectivity between Admission
Office located in Kolkata and the campus located in Ana Nagar from the following options:
i. Telephone line
ii. Fixed-Line Dial-up connection
iii. Co-axial Cable Network
iv. GSM
v. Leased line
vi. Satellite Connection
OR
Suggest an efficient device to be installed in each of the blocks to connect all the computers.
35. Read the text carefully and answer the questions:
Consider the following tables GAMES and PLAYER:
Table: GAMES

GCode Game Name Type Number Prize Money Schedule Date


101 Carom Board Indoor 2 5000 23-Jan-2004
102 Badminton Outdoor 2 12000 12-Dec-2003
103 Table Tennis Indoor 4 8000 14-Feb-2004
105 Chess Indoor 2 9000 01-Jan-2004
108 Lawn Tennis Outdoor 4 25000 19-Mar-2004

Table: PLAYER

PCode Name GCode


1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
i. What do you understand by primary key and candidate keys?
ii. Write SQL commands for the following statements:
i. To display the name of all GAMES with their GCodes.
ii. To display details of those GAMES which are having PrizeMoney more than 7000.
iii. Write SQL commands for the following statements:

7 / 15
i. To display the content of the GAMES table in ascending order of Schedule Date.
ii. To display sum of PrizeMoney for each type of GAMES.

8 / 15
Class 12 - Computer Science
Sample Paper - 11 (2022-23)

Solution

Section A
1. (a) True
Explanation: True
2. (a) Inner join
Explanation: Inner join
3. (a) show databases;
Explanation: show databases;
4. (c) a stack
Explanation: Stack stores the parameters and local variables of a function call.
5. (a) analog signal
Explanation: An analog signal is any continuous signal for which the time-varying feature of the signal is a
representation of some other time-varying quantity, i.e., analogous to another time-varying signal. Analog signals
produce too much noise. Examples:- Human voice, Thermometer, Analog phones, etc.
6. (d) b, c, f
Explanation:
In file path, '\r' is a carriage return character, to normalise it we use another / before it or use 'r' prefix before the
file path.
We do not need to mention the file keyword to input the file path in open function.
To practice more questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8 App to create
similar papers with their own name and logo.
7. (c) All of these
Explanation: The data dictionary is structured in tables and views just like other database data.
8. (a) COUNT(*)
Explanation: COUNT(*) takes null value row in to consideration.
9. (b) Program
Explanation: Program
10. (c) strip()
Explanation: strip()
11. (b) TOP
Explanation: TOP is the pointer associated with the stack.
12. (c) Ctrl + Break
Explanation: Ctrl + Break
13. (c) VB Script
Explanation: VB Script and Java Script are examples of client-side scripting languages. Rest all are server-side scripting
languages.
14. (b) <
Explanation: <
15. (b) 1
Explanation: Parity refers to the number of bits set to 1 in the data item
Even parity - an even number of bits are 1

9 / 15
myCBSEgu
ide
Odd parity - an odd number of bits are 1
A parity bit is an extra bit transmitted with a data item, chose to give the resulting bits even or odd parity
Odd parity - data: 10010110, the parity bit 1
16. (b) a process in one device is able to exchange information with a process in another device
Explanation: Two devices are in network if a process in one device is able to exchange information with a process in
another device.
17. (b) Both A and R are true but R is not the correct explanation of A.
Explanation: Python Lists can contain data of different types. The items stored in the list are separated with a comma (,)
and enclosed within square brackets []. List slicing returns a new list from the existing list.
18. (a) Both A and R are true and R is the correct explanation of A.
Explanation: We can perform any operation on the file externally using the file system which is currently opened in
Python; hence it is good practice to close the file in python program once all the desired operations are carried out in the
file.
Section B
19. The wireless networks employ a protocol called CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance)
to avoid collisions in the network.
It is a multiple access method in which the carrier is sensed first and a node attempts to avoid collisions by transmitting
only when it senses that the carrier is idle i.e., no other node is transmitting data.
Wireless networks use CSMA/CA as they cannot detect collisions; hence they avoid it.
20. 4 5 6 (Note. 0o7 is a valid integer, written in octal forming)

OR

{'Apple' : 1}
{'Apple' : 1, 'Banana' : 1}
{'Apple' : 1, 'Banana' : 1, ’apple’ : 1}
{'Apple' : 1, 'Banana' : 2, 'apple' : 1}
3
21. import MySQLdb
db = MySQLdb.connect('localhost', 'HRMan', 'HRMANexe@pwd', 'HTMdb')
cursor = db.cursor()
sql = """UPDATE Employee set Age=
Age+1 try:
db.execute(sql)
db.commit()
except:
db.rollback()
db.close()
22. Answer:
i. It will extract rows from staff table where person_id is 1 or 3 or 4.
ii. This method sends a COMMIT statement to the MySQL server, committing the current transaction. Since by
default Connector/Python does not auto-commit, it is important to call this method after every transaction that
modifies data for tables.
23. The program will print nothing as before reaching the print statement in the function, the program control encounters the
return statement.
24. The problem with the above code is inconsistent indentation. In Python, we cannot indent a statement unless it is inside a
suite and we can indent only as much as required.

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly


10 / 15
prohibited.
myCBSEgu
ide
Thus, corrected code will be:
name = "Rehman"
print("Greetings !!!")
print("Hello", name)
print ("How do you do?")

OR

Advantage of pop() method over a del keyword is that it provides the mechanism to print desired value if tried to remove
a non-existing dictionary pair.
Syntax

dictionary_name.pop(key, 'Text')

25. def writediary():


file_obj = open ("diary.txt", 'w')
file_obj.write("My Day Routine")
file_obj.write("My Office Time")
file_obj.write("My free Time")
file_obj.write("End of Diary")
#writediary() function enters the four line of text into the diary.txt file.

OR

def displayMeMy():
num = 0
f = open("story.txt",
"rt") N = f.read()
M = N.split()
for x in M:
if x == "Me" or x == "My":
print(x)
num = num+1
f.close()
print("Count of Me/My in file:", num)
Section C
26. Answer:

i. for i in range(3,5)
if(i==4):
print("Welcome")
else:
print("No entry")
print("value of i",i)

ii. P
R
O
G

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly


11 / 15
prohibited.
myCBSEgu
ide
R
A
M
27. The given query is erroneous because it involves pattern matching.
The correct operator to be used for pattern matching is LIKE. Also, there is NULL comparison and for it also incorrect
operator is used. The correct operator for NULL comparison is IS. Thus, the correct SQL statement will be :
SELECT Name, class FROM students WHERE Stream-name IS NULL OR Stream-name LIKE "%computers" ;

OR

When we use GROUP BY clause (for grouping of data) and ORDER BY clause (for sorting data) together, the ORDER
BY clause always follows other clauses. That is, the GROUP BY clause will come before the ORDER BY clause. For
example In this query,
SELECT user_id, SUM(score) AS total_score FROM user_score GROUP BY user_id ORDER BY user_id ASC;
28. def OddSum(NUMBERS) :
odd_sum = 0
for num in range (len(NUMBERS)):
if (NUMBERS[num] % 2 != 0:
odd_sum = odd_sum + NUMBERS [num]
print odd_sum
29. import pickle
def CountRec():
fobj = open("STUDENT.DAT",
"rb") num = 0
try:
while True:
rec = pickle.load(fobj)
if rec[2] > 75:
print(rec[0], rec[1], rec[2], sep= "\t")
num = num + 1
except:
fobj.close()
return num
30. import random
def randomNDigitNumber(n):
num = " "
firstlteration = True
for i in range(n):
randomDigit = " "
if firstlteration:
randomDigit = str(random.randint(1, 9))
firstlteration = False
else:
randomDigit = str(random.randint(0, 9))
num = randomDigit + num
return num
print(randomNDigitNumber(7))

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly


12 / 15
prohibited.
myCBSEgu
ide
OR

i. The default parameters are parameters with a default value set to them. This default value is automatically considered
as the passed value WHEN no value is provided for that parameter in the function call statement.
Thus default arguments are useful when we want to skip an argument in a function call statement and use the default
value for it instead.
ii. The keyword arguments give complete control and flexibility over the values sent as arguments for the
corresponding parameters. Irrespective of the placement and order of arguments, keyword arguments are correctly
matched. A keyword argument is where you provide a name to the variable as you pass it into the function.
Section D

31. Book = [ ]
def Addnew (Books, Name):
Book.append(Name)
print("Book", "Name", "inserted")
def Remove (Books) :
if Books == [ ] :
print ("stack is empty")
else :
print ("Book ",Books.pop(), "deleted")

32. Answer (i) & (ii) OR (iii) & (iv) i.


Text File Binary File
It stores information just in the form as is
It stores information in ASCII or Unicode characters.
stored in memory.
In-text file, each line of text is terminated with a special character In binary files, there is no delimiter for
known as EOL (End of Line) character. lines.
In text files newline is stored as a combination of carriage return '\r' and In binary files newline is stored only as
'\n' ii. User define function to display total number of'\n'.
words in a file:
def countwords():
s=open ("Quotes.txt", 'r')
f = s, read()
z = f. split()
count=0
for i in z:
count=count +1
print("Total number of words", count)
iii. def CountDorM():
ctr = 0
with open('DELHI.txt', 'r') as file_obj:
while True:
line=file_obj.readline()
if not line: break
if line[0] == 'D' or line[0] == ‘M’ :
ctr = ctr + 1

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly


13 / 15
prohibited.
myCBSEgu
ide
if count == 0:
print("no line starts with D or M")
else:
print ("Number of lines starting with D or M =",ctr)
Here, Function CountDorM returns the number of lines starting with D or M in "DELHI.txt" file.
iv. import pickle
file = open("log.dat",'rb')
try:
while True:
y = load(file)
#print y
X=str.find('Xerror') #pos
if X != -1:
count ++
y.split()
n=
y.lstrip(‘Xerror:’) m
= int(n)
sum = sum + m
print ("No of error lines",count
print ("Error",sum)
except:
print ('Error')
To practice more questions & prepare well for exams, download myCBSEguide App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8 App to create
similar papers with their own name and logo.
33. i. SELECT Acode, ActivityName FROM ACTIVITY ORDER BY Acode DESC;
ii. SELECT Stadium, SUM(PrizeMoney) FROM ACTIVITY GROUP BY Stadium;
iii. SELECT Name, Acode FROM COACH ORDER By Acode;
iv. SELECT * FROM ACTIVITY WHERE SchduleDate < '01-Jan-2004' ORDER BY ParticipantsNum;

OR

a. Primary Key of CARDEN = Ccode CARDEN Alternate Key = CarName: Primary key of Customer = Code
Alternate Key of Customer = Cname 2
b. i. SELECT CarName FROM CARDEN WHERE Color = "SILVER";
ii. SELECT CarName, Make, Capacity FROM CARDEN ORDER BY Capacity DESC;
iii. SELECT MAX(Charges) FROM CARDEN;
iv. SELECT Cname, CarName From CUSTOMER CARDEN, WHERE CUSTOMER. Ccode = CARDEN. Ccode;
c. i. 4

ii. MAX(Charges) MIN(Charges)


35 12
iii. 5
iv. SX4
C Class
Section E
34. 34. i. The server should be Dedicated server.

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly


14 / 15
prohibited.
myCBSEgu
ide
ii. The most suitable place to house the server is Science Block as it has the maximum number of computers. Thus,
reducing the cabling cost and increase the efficiency of the network.
iii. Satellite Connection Or Leased line

OR

SWITCH
35. i. Primary Key is a unique and non-null key, which is used to identify a tuple uniquely. If a table has more
than one such attributes which identify a tuple uniquely than all such attributes are known as candidate keys.
ii. i. SELECT GameName, GCode FROM GAMES;
ii. SELECT * FROM Games WHERE PrizeMoney > 7000;
iii. i. SELECT * FROM Games ORDER BY ScheduleDate;
ii. SELECT SUM(Prizemoney) FROM Games GROUP BY Type;

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly


15 / 15
prohibited.

You might also like