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

PB 1 - ComputerScience MS

This document contains a pre-board exam for Class 12 Computer Science. It has 26 multiple choice and short answer questions covering topics like operators, data types, file handling, SQL, functions, loops, and more. The exam has 3 sections - Section A with 17 multiple choice questions worth 1 mark each, Section B with 5 short answer/code writing questions worth up to 2 marks each, and Section C with 4 SQL queries worth up to 3 marks.

Uploaded by

klaus Mikaelson
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)
60 views

PB 1 - ComputerScience MS

This document contains a pre-board exam for Class 12 Computer Science. It has 26 multiple choice and short answer questions covering topics like operators, data types, file handling, SQL, functions, loops, and more. The exam has 3 sections - Section A with 17 multiple choice questions worth 1 mark each, Section B with 5 short answer/code writing questions worth up to 2 marks each, and Section C with 4 SQL queries worth up to 3 marks.

Uploaded by

klaus Mikaelson
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/ 16

KENDRIYA VIDYALAYA SANGATHAN PATNA REGION

Class: XII Session: 2022-23


Computer Science (083)
Preboard-1 (Theory)
KVP/083/C
Maximum Marks: 70 Time Allowed: 3 hours

SECTION A

(1 mark to be awarded for every correct answer)

1. Which one of the following is a valid relational operator: 1


i. +=
ii. ==
iii. And
iv. **

Ans. ==

2. Identify the mutable data type(s) : 1


i. string
ii. tuple
iii. List
iv. int
Ans: (iii) List

3 Which one of the following is the valid identifier in Python? 1


a. _a
b. pass
c. Roll.no
d. 1sum

Ans: (a) _a

4. Consider a string S=”ComputerScience”. Which statement out of the following will result in an 1
error:
a. S=S*2
b. S=S+”123”
c. S[0]=”c”
d. S1=S[0:5]

Ans: (a) S[0]=”c”

1
5. What will be the output of the following Python code? 1
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
a) [2, 3, 9]
b) [1, 2, 4, 3, 8, 9]
c) [1, 4, 8]
d) (1, 4, 8)

Ans: c) [1, 4, 8]

6. Which of the following mode in file opening statement results or generates an error if 1
the file does not exist?

(a) a+ (b) r+ (c) w+ (d) None of the above

Ans: (b) r+

7. Which statement defined below can create a dictionary? 1


A. d = {“Computer”:100, “Programming”:95}
B. d = {100:” Computer”, 95:”Programming”}
C. d = { }
D. All the above.

Ans: D. All the above.

8. Which of the following is a DML command? 1


(b) a) CREATE b) ALTER c) INSERT d) DROP

Ans: (c) insert

9. Which of the following statement(s) would give an error after executing the following 1
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
Ans: (b) – Statement 4

2
10. Which of the following constraint does not enforce uniqueness? 1
a) UNIQUE
b) Primary key
c) Foreign key
d) None of the mentioned

Answer: c
Explanation: FOREIGN KEY constraints identify and enforce the relationships between
tables.
11. The correct syntax of seek() is:
(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
Ans: (a) file_object.seek(offset [, reference_point])

12. Mr Riyan from Delhi wants to install some software in his client’s computer who is in Jaipur
through remote login. Which protocol out of the following will be used in this scenario:
A. SMTP
B. FTP
C. PPP
D. Telnet

Ans: d) telnet

13. A device used to connect dissimilar networks is called


...........
a) hub b)gateway c) switch d) bridge

Ans: b) gateway

14. What will the following expression be evaluated to in Python? print(15.0 / 4 +


(8 + 3.0))

(a) 14.75 (b)14.0 (c) 15 (d) 15.5

Ans: (a) 14.75

15. In RDBMS, there can be multiple ______________ 1


Primary Key
Candidate Key

Answer is candidate keys

3
16. Which of the following is not a cyber crime: 1
i. Phishing
ii. Identity Theft
iii. Online fraud
iv. Disliking a Social Media post

Ans: (4) Disliking a Social Media post

Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice
(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 a function call statement match the number and order 1
of arguments as defined in the function definition, such arguments are called positional
arguments.
Reasoning (R):- During a function call, the argument list first contains default argument(s)
followed by positional argument(s).

Ans: (c) A is True but R is False

18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks 1
like a text file.
Reason (R): The information is organized with one record on each line and each field is
separated by comma.

Ans: (a) Both A and R are true and R is the correct explanation for A

SECTION B
19. Number = 250 2
while Number<=1000:
if Number >= 750:
print (Number)
Number = Number+100
else:
print (Number*2)
Number = Number+50

(½ mark for each correct correction made and underlined.)

4
20. A computer virus is malware attached to another program (such as a document), 2
which can replicate and spread after an initial execution on a target system where
human interaction is required.
WORMS
•A computer worm is a standalone malware computer program that replicates itself in
order to spread to other computers.
2 mark for any correct difference.

OR
Star topology is a topology in which all devices are connected to a central hub. Bus
topology is a topology where each device is connected to a single cable which is known
as the backbone. ... Star topology does not have any terminator. Bus topology has a
terminators at both end of the network..

1 mark for any correct difference.


1 mark for layout

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


myexam="@@CBSE Examination 2022@@"

Write the output of: print(myexam[::-2])

1
Ans: @20 otnmx SC@

(1 mark for the correct answer)

b. Write the output of the code given below:


my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())

Ans: dict_items([('name', 'Aman'), ('age', 27), ('address', 'Delhi')])

(1 mark for the correct answer)

22. The PRIMARY KEY constraint uniquely identifies each record in a table. 2
Primary keys must contain UNIQUE values, and cannot contain NULL
values.
A table can have only ONE primary key; and in the table, this primary key
can consist of single or multiple columns (fields).
1 mark for definition 1 mark for example

5
23. 2
(a) Telephone line, Twisted Pair Cable, Coaxial Cable, Fiber Optics
(1 mark for correct answer)

(b) What is the use of TELNET?

Ans: TELNET is used to access a remote computer / network.

(1 mark for correct answer)

24 (1 mark for each correct Diffrences)

OR
Ans:
DDL- ALTER, DROP
DML – INSERT, UPDATE

(½ mark for each correct categorization)

25. Predict the output of the Python code given below: 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=' ')

Ans: 22 # 40 # 9 # 13 #

(½ mark for the correct digit with a #)

OR

6
Predict the output of the Python code given below:

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)

Ans: (22,44,66)

( ½ mark for each correct digit , ½ mark for enclosing in parenthesis)

SECTION C

26. i) Select Item_Name, max(Price), count(*) from Item group by 1+2


Item_Name ;

i) Personal Computer 37000 3


Laptop 57000 2

ii) Select CName, Manufacturer from Item, Customer where Item.ID


=Customer.ID;

ii) N Roy PQR


R Singh XYZ
R Pandey COMP
C Sharma PQR
K Agarwal ABC

iii) Select Item_Name, Price * 100 from Item where Manufacturer


=“ABC”;

iii) Personal Computer 3500000


Laptop 5500000

27. Write a method COUNTLINES() in Python to read lines from text file 3
‘TESTFILE.TXT’ and display the lines which are not starting with any vowel.

7
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 COUNTLINES() function should display the output as: The number
of lines not starting with any vowel - 1

Ans: def COUNTLINES() : file = open


('TESTFILE.TXT', 'r') lines =
file.readlines() count=0 for
w in lines :
if (w[0]).lower() not in 'aeoiu'
count = count + 1
print ("The number of lines not starting with any
vowel: ", count) file.close()

COUNTLINES()

( ½ mark for correctly opening and closing the file


½ for readlines()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output)

OR

Write a function ETCount() in Python, which should read each character of a text file
“TESTFILE.TXT” and then count and display the count of occurrence of alphabets E and
T individually (including small cases e and t too).

Example:

If the file content is as follows:

Today is a pleasant day.


It might rain today.
It is mentioned on weather sites

The ETCount() function should display the output as:


The number of E or e: 6
The number of T or t : 9

Ans:
def ETCount() :

8
file = open ('TESTFILE.TXT', 'r') lines
= file.readlines() countE=0
countT=0
for w in lines : for ch
in w: if ch in 'Ee':
countE = countE + 1
if ch in 'Tt': countT=countT
+ 1
print ("The number of E or e : ", countE) print
("The number of T or t : ", countT) file.close()

(½ mark for correctly opening and closing the file


½ for readlines()
½ mark for correct loops
½ for correct if statement
½ mark for correctly incrementing counts
½ mark for displaying the correct output)

Note: Any other relevant and correct code may be marked

28. (i) SELECT SUBJECT,COUNT(*) FROM SCHOOL GROUP BY SUBJECT HAVING COUNT(*)>=2; 3

+-----------+----------+
| SUBJECT | COUNT(*) |
+-----------+----------+
| ENGLISH | 2|
| PHYSICS | 3|
| +-----------+----------+
½ MARK FOR EACH CORRECT ANSWER

(ii) SELECT COUNT(DISTINCT SUBJECT) FROM SCHOOL;

+-------------------------+
| COUNT(DISTINCT SUBJECT) |
+-------------------------+
| 4 |
+-------------------------+
1 MARK FOR CORRECT ANSWER

(iii) SELECT TEACHERNAME, SUBJECT,DESIGNATION FROM SCHOOL,ADMIN WHERE


SCHOOL.ADMINID=ADMIN.ADMINID AND PERIODS<=24;

9
+---------------+---------+----------------+
| TEACHERNAME | SUBJECT | DESIGNATION |
+---------------+---------+----------------+
| SUPRIYA SINGH | ENGLISH | VICE PRINCIPAL |
| YASH KUMAR | MATH | HOD |
| GAGAN SINGH | PHYSICS | HOD |
+---------------+---------+----------------+
1 MARK FOR CORRECT ANSWER ½ MARK FOR PARTIALLY CORRECT ANSWER

29. def f(L,L1): 3


sum=0
l2=[]

for i in range(len(L)):
sum=L[i]+L1[i]
l2.append(sum)
print(l2)

½ mark for function header


2 marks for logic
½ mark for printing new list

10
30. def PushNV(N): 3
for W in N : for C in W :
if C.upper() in 'AEIOU':
break
else:
NoVowel.append(W)
All=[]
NoVowel=[]

for i in range(5) :
All.append(input('Enter a Word: '))
PushNV(All)
while NoVowel :
print(NoVowel.pop(), end=' ')
else : print('EmptyStack')

OR

Any other correct equivalent code

(½ mark for checking vowels correctly, ignore case sensitivity)


(½ mark for pushing strings into the stack NoVowel)
(½ mark for reading 5 words from the users)
(½ mark for assigning 5 words into All)
(½ mark for writing correct code to pop and display the words from NoVowel)
(½ mark for writing correct code to check empty stack and display the message 'EmptyStack')

OR

def Push3_5(N):
for i in N :
if i%3==0 or i%5==0 :
Only3_5.append(i)
NUM=[]
Only3_5=[]

for i in range(5):
NUM.append(int(input('Enter an Integer: ')))

Push3_5(NUM)

while Only3_5 :
print(Only3_5.pop(), end=' ')
else :
print('StackEmpty')
OR
Any other correct equivalent code
11
(½ mark for checking divisibility correctly)
(½ mark for pushing integers into the stack Only3_5)
(½ mark for reading 5 integers from the users)
(½ mark for assigning those 5 integers into NUM)
(½ mark for writing correct code to pop and display the integers from Only3_5)
(½ mark for writing correct code to check empty stack and display the message 'StackEmpty')

SECTION D

31. (i) Suggest network type (out of LAN, MAN, WAN) for connecting each of the following
set of their offices :
• Head Office and Tech Office
• Head Office and Coimbatore Office
Ans : (i) · Head Office and Tech Office: LAN
1
· Head Office and Coimbatore Office: WAN

(ii) Which device will you suggest to be procured by the company for connecting all the
computers within each of, their offices out of the following devices ?
• Modem
• Telephone 1
• Switch/Hub
Ans : Switch/Hub

(iii) Which of the following communication media, will you suggest to be procured by the company
for connecting their local offices in New Delhi for very effective and fast communication ?
• Ethernet Cable
• Optical Fiber 1
• Telephone Cable
Ans : Optical fiber
(iv)Suggest the best draw the cable layout (Block to Block) to economically
connect 1

(v) Suggest a cable/wiring layout for connecting the company’s local offices located in New Delhi. Also,,
suggest an effective method/technology for connecting the company’s regional offices at “Kolkata”,
“Coimbatore” and “Ahmedabad”.
1
Optical Fiber/Star Topology
Wireless

12
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='@')

Ans:

Output:
7@[3, 4]
8@[8]

(1 mark for each correct ans)

(b) Ans:
Statement 1: con1.cursor()

Statement 2: mycursor.execute(querry)

Statement 3: con1.commit()

(1 mark for each correct answer)

OR

(a)Ans:
@ss

(b) (Die to Live 78127873915)


(Again? 23686286243)
(Ushakaal 12678987036)
(ushakiran 42568987036)

13
33. What is the advantage of using a csv file for permanent storage? 5
Write a Program in Python that defines and calls the following user defined functions:

a) ADD() – To accept and add data of an employee to a CSV file ‘record.csv’. Each
record consists of a list with field elements as empid, name and mobile to
store employee id, employee name and employee salary respectively.
b) COUNTR() – To count the number of records present in the CSV file named
‘record.csv’.

Ans:
Advantage of a csv file:
• It is human readable – can be opened in Excel and Notepad applications
• It is just like text file

Program:

import csv def


ADD(): fout=open("record.csv","a",newline="\n")
wr=csv.writer(fout)
empid=int(input("Enter Employee id :: ")) name=input("Enter
name :: ")
mobile=int(input("Enter mobile number :: "))
lst=[empid,name,mobile] ---------1/2 mark wr.writerow(lst)
---------1/2 mark fout.close()
def COUNTR():
fin=open("record.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(len(d))
fin.close()
ADD()
COUNTR()

(1 mark for advantage


½ mark for importing csv module
1 ½ marks each for correct definition of ADD() and
COUNTR()
½ mark for function call statements )

14
OR

Give any one point of difference between a binary file and a csv file. Write a
Program in Python that defines and calls the following user defined functions:

a) add() – To accept and add data of an employee 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.

b) search()- To display the records of the furniture whose price is more than 10000.

Ans:
Difference between binary file and csv file: (Any one difference may be given)
Binary file:
• 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

Program:

import csv def add():


fout=open("furdata.csv","a",newline='\n')
wr=csv.writer(fout)
fid=int(input("Enter Furniture Id :: "))
fname=input("Enter Furniture name :: ")
fprice=int(input("Enter price :: "))
FD=[fid,fname,fprice] wr.writerow(FD)
fout.close()
def search():
fin=open("furdata.csv","r",newline='\n')
data=csv.reader(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")

15
fin.close() add()
print("Now displaying") search()

(1 mark for difference


½ mark for importing csv module
1 ½ marks each for correct definition of add() and search()
½ mark for function call statements )

SECTION E
34. (a) BookNo 1+1+2
(b) Degree=4 Cardinality =7
(c) UPDATE collections SET quantity = quantity + 20 WHERE quantity < 50;
(d) DELETE FROM Collections;

35. (i) pickle


(ii) Wb
(iii) pickle.dump(e,f2)
(iv) rename()

1 MARKS FOR EACH STATEMENT

16

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy