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

Set 2 PDF

This document contains the instructions and questions for a Computer Science pre-board examination. It has 5 sections with a total of 70 multiple choice and written response questions. The questions cover topics like Python programming, databases, networking and computer fundamentals. Students are instructed to answer all questions in 3 hours using Python language where required. Sample questions are provided to cover concepts like loops, functions, strings, dictionaries, SQL queries and relational database concepts.

Uploaded by

Mohamed Anas
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)
439 views15 pages

Set 2 PDF

This document contains the instructions and questions for a Computer Science pre-board examination. It has 5 sections with a total of 70 multiple choice and written response questions. The questions cover topics like Python programming, databases, networking and computer fundamentals. Students are instructed to answer all questions in 3 hours using Python language where required. Sample questions are provided to cover concepts like loops, functions, strings, dictionaries, SQL queries and relational database concepts.

Uploaded by

Mohamed Anas
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/ 15

BANGALORE SAHODAYA SCHOOLS COMPLEX ASSOCIATION (BSSCA)

Class: XII
PRE-BOARD EXAMINATION (2022-23)
SET 2
DATE : 11.01.23 Max marks : 70
SUBJECT: Computer Science (083) Time : 3 hours
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. Write the type of the tokens for the following 1
i. 35 ii. ,
2. Given the list beow predict the output 1
odd_half = [x // 2 for x in range(2, 10) if x % 2 == 1]
print (odd_half)

3. Find the output for the following 1


birds=["parrot", "owl", "sparrow", "crow", "eagle", "vulture", "pigeon"]
del birds[4]
birds.remove("vulture")
birds.pop(3)
print(birds)
4. What value does the following expression evaluate to?
>>>2 + 9 * ((3 * 12) – 8) / 10
a. 27
b. 27.2
c. 30.8
d. None of these

Page-1
5. What will be the output of the following Python code? 1
count={}
count[(1,2,4)] = 5
count[(4,2,1)] = 7
count[(1,2)] = 6
count[(4,2,1)] = 2
tot = 0
for i in count:
tot=tot+count[i]
print(len(count)+tot)

a. 16
b. 17
c. 25
d. Tuples can’t be made keys of a dictionary
6. The readlines() method returns ____________ 1
a. Str
b. a list of lines
c. a list of single characters
d. a list of integers
7. A(n) ____________ in a table represents a logical relationship among a set of
values. 1
a. Tuple
b. Attribute
c. Key
d. Entry
8. What does comparing a known value with NULL result into? 1
a. zero
b. a positive value
c. a negative value
d. null
9. In a Python program, a control structure: 1
a. Defines program-specific data structures
b. Directs the order of execution of the statements in the program
c. Dictates what happens before the program starts and after it terminates
d. None of the above

Page-2
10. Suppose you have two columns named student_name and student_department inside
table student_details and you are asked to update the value of these two columns
where ID=4 then what statement you will write? 1

a. UPDATE student_details SET Student_name="ram", Student_department =


'Chemical' WHERE ID='4';
b. UPDATE table student_details SET column_name Student_name="ram",
Student_department = 'Chemical' WHERE ID='4';
c. UPDATE student_details SET Student_name="ram" and Student_department =
'Chemical' WHERE ID='4';
d. UPDATE table student_details SET Student_name="ram", Student_department =
'Chemical' WHERE ID='4';
11. What happens if no arguments are passed to the seek function? 1
a. file position is set to the start of file
b. file position is set to the end of file
c. file position remains unchanged
d. error
12. Which clause is used to “Modify the existing field of the table”? 1
a. ALTER
b. UPDATE
c. SELECT
d. MODIFY
13. Which of the following devices modulates digital signals into analog signals that
can be sent over telephone lines. 1
a. Router
b. Gateway
c. Bridge
d. Modem
14. What will be the output of the following Python code? 1
i=5
while True:
if i%0O9 == 0:
break
print(i)
i += 1

Page-3
a. 5 6 7 8
b. 5 6 7 8 9
c. 5 6 7 8 9 10 11 12 13 14 15 ….
d. Error
15. Foreign Key in a table is used to enforce 1
a. Data dependency
b. ReferentialIntegrity
c. Views
d. IndexLocations
16. Which attribute is used to return number of rows that are affected by an execute()
method. 1
a. rows()
b. count()
c. rowcount()
d. returncount()
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
appropriate choice.
17. Assertion - A function ends the moment it reaches a return statement or all the
statements in function body have been executed. 1
Reason – Return statement ends a function execution even if it is in the middle of
the function.
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- The open a file one should use the open() function, open() is a built
in function 1
Reason - The open () functions returns a file object, it is used to read or modify the
file accordingly.
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.

Page-4
SECTION B
19. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code 2
def sum(c)
s=0
for i in Range(1, c+1)
s=s+i
return s
print(sum(5)
20. Differentiate two pints between PAN and LAN types of networks. 2
OR
Write two differences between Packet Switching and Message Switching

21. a. PREDICT THE OUTPUT 2


t1=("Bangalore",[1,2,'3'],'S',(3,4,6),"Centre",10)
print(t1[-2:]+t1[3])

b. What will be the output of following program:


my_dict = {}
my_dict[1] = 1
my_dict['1'] = 2
my_dict[1.0] = 4
sum = 0
for k in my_dict:
sum += my_dict[k]
print (sum)

22. What are aggregate and scalar functions in MYSQL? Give one example for each
23. 1+1
a. Expand the following terminologies.
i.CDMA ii. XML.
b. Write two characteristics of Wi-fi

Page-5
24. Predict the output of the Python code given below: 2
def Indirect(temp = 20):
for i in range(10,temp+1, 5):
print(i, end = ' ')
print()
def Direct(num):
num = num + 10
Indirect(num)
print ("Number ", num)
number = 20 # main program
Direct(number)
OR
Predict the output of the Python code given below:
str1=list("Sn04")
for i in range(len(str1)):
if i==3:
x=int(i)
x+=x-3
str1[i]=x
elif (str1[i].islower()):
str1[i]=str1[i].upper()
else:
str1[i]=str1[i]*2
print(str1)

25. Differentiate between Candidate key and Primary key in context of RDBMS.
Illustrate with an example. 2
OR
What are DDL and DML? Write any two commands of DDL and DML in MYSQL

SECTION C
26. 1+2
a. Consider the two tables : PRODUCT and CLIENT

Page-6
Table : PRODUCT
Pid ProductName Manufacturer Price
TP01 Talcom Powder LAK 40
FW05 Face Wash ABC 45
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120
FW12 Face Wash XYZ 95

Table : CLIENT
Cid ClientName City Pid
01 Cosmetic Shop Delhi FW05
06 Total Health Mumbai BS01
12 Live Life Delhi SH06
15 Pretty Women Delhi FW12
16 Dreams Bangalore TP01

What will be the output of the following statement?


SELECT CLIENTNAME, CITY, PRODUCTNAME, PRICE FROM PRODUCT,
CLIENT WHERE PRODUCT.PID = CLIENT.PID

b. Table HOSPITAL
No Name Age Department Dateofadm Charges Sex
1 Arpit 34 Surgery 21/01/04 300 M
2 Anush 60 ENT 11/04/05 250 M
3 Nilofer 45 Orthopedic 19/11/04 500 F
4 Jackie 47 Surgery 20/05/06 600 F
5 Bret 20 ENT 19/04/05 200 M
6 Anthea 46 ENT 23/09/05 200 F
7 Bindu 38 Cardiology 15/08/04 450 F
8 Deepak 25 Cardiology 14/11/05 450 M
9 Zain 9 Nuclear Medicine 14/12/06 700 M
10 Zeba 47 Gynecology 1/1/2006 350 F
i. select name, age, sex from hospital where department like "cardiology";
ii. select name, dateofadm from hospital where department = "ENT" and sex like 'F'
iii. select department, count(*), min(charges) from hospital group by department
having count(department)>2;
iv. select distinct(department) from hospital order by department;

27. Write a method countcap( ) in python to count the number of upper case alphabets
present in a text file “ARTICLE.txt” 3
Example :

Page-7
If the file contains the given below content:
A piece of writing other than fiction or poetry that forms a separate part of a
publication (as a Magazine or Newspaper)
Then the countcap( ) has to give output as :
The number of capital case alphabets are : 3
OR
Write a method RevText() to read a text file “input.txt” and print the text in reverse order.
Example:
If the file content is as follows: I LOVE MY NATION
Output will be: NOITAN YM EVOL I

28. a. Write the outputs of the SQL queries (i) to (iv) based on the relations Club and
Coach given below: 2+1
Table : Club
Coach-id CoachName Age Sports DateOfApp Pay Sex
1 KUKREJA 35 KARATE 27/03/1996 1000 M
2 RAVINA 34 KARATE 20/01/1998 1200 F
3 KARAN 34 SQUASH 19/02/1999 2000 M
4 TARUN 33 BASKETBALL 01/01/1999 1500 M
5 ZUBIN 36 SWIMMING 12/01/1998 750 M
6 KETAKI 36 SWIMMING 24/02/1997 800 F
7 ANKITA 39 SQUASH 20/02/1998 2200 F
8 ZAREEN 37 KARATE 22/02/1997 1100 F
9 KUSH 41 SWIMMING 13/01/1997 900 M
10 SHAILYA 37 BASKETBALL 19/02/1998 1700 M
Table :Coach
Sports person Sex Coach-id
AJAY M 1
SEEMA F 2
VINOD M 1
TANEJA F 3
VIKRAM M 9

i. SELECT COACHNAME,PAY FROM CLUB WHERE PAY>1500 ORDER BY


DATEOFAPP ASC;
ii. SELECT COACHNAME, AGE, PAY, 15/100*PAY+PAY BONUS FROM CLUB
WHERE DATEOFAPP < '01-JAN-1998';

Page-8
iii. SELECT COACHNAME, SPORTSPERSON FROM CLUB, CLUBPERSON
WHERE CLUB.SEX LIKE 'M' AND CLUBPERSON.SEX LIKE 'F'AND
CLUB.COACHID = CLUBPERSON.COACHID;
iv. SELECT SUM(PAY) FROM CLUB WHERE DATEOFAPP > '31-JAN-1998';

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

29. Write a void function that receives a 4-digit no. and calculates the sum of the
squares of each digit in the number. 3
Example :
Enter a 4-digit no.1234
Sum of squares of digits 30

30. Write functions of a program to implement a stack for these book details(bookno,
bookname). That is, now each item of node of stack contains 2 types of information
as a list element. Implement Push and Display operations for the stack of books.
OR
Write a function in python named PUSH(STACK, SET) where STACK is list of
some numbers forming a stack and SET is a list of some numbers. The function will
push all the EVEN elements from the SET into a STACK implemented by using a
list. Display the stack after push operation. 3

SECTION D

31. Intelligent Hub India is a knowledge community aimed to uplift the standard of
skills and knowledge in the society. It is planning to setup its training centres in
multiple towns and villages pan India with its head offices in the nearest cities.
They have created a model of their network with a city, a town and 3 villages as
follows: 5
As a network consultant, you have to suggest the best network related solutions for
their issues/problems raised in (i) to (v), keeping in mind the distances between
various locations and other given parameters.

Page-9
i. Suggest the most appropriate location of the SERVER in the YHUB (out of the
4 locations), to get the best and effective connectivity. Justify your answer. 1
ii. Suggest the best wired medium and draw the cable layout (location to location)
to efficiently connect various locations within the YHUB. 1
iii. Suggest a device/software to be installed in the Kashipur Campus to take care of
data security. 1
iv. Which hardware device will you suggest to connect all the computers within
each location of YHUB? 1
v. Which service/protocol will be most helpful to conduct live interactions of
Experts from Head Office and people at YHUB locations? 1

32. 2+3
a. Predict the output of the code given below
Page-10
def Display(str):
m=" "
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('CBSE@dec22')

b. The code given below inserts the following record in the table Student:
rno – integer
Name – string
cls – integer
Mks – integer
Note the following to establish connectivity between Python andMYSQL:
✓ Username is root
✓ Password is tiger
✓ The table exists in a MYSQL database named class12.
✓ The details (rno, name, cls and mks) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table
Student.
Statement 3 – to add the record permanently in the database
import mysql.connector as m
def connecting():
con1=m.connect(host="localhost",user="root", password="tiger",
database="class12")
mycursor= ________________#Statement 1
rno=int(input("Enter Roll Number :: "))
name=input("Enter name :: ")

Page-11
cls=int(input("Enter class :: "))
mks=int(input("Enter Marks :: "))
querry="insert into student values ({},'{}',{},{})" . format
(rno,name,cls,marks)
____________________#Statement 2
____________________# Statement 3
print("Data Added successfully")
OR
a. Predict the output of the following program
X = 100
def Change(P=10, Q=25):
global X
if P%6==0:
X+=100
else:
X+=50
print(P,'#',Q,'$')
Change()
Change(18,50)

b. The code given below reads the following record from the table named Book and
displays only those records with the book price greater than 250 rs.:
BNo – integer
BName – string
BPrice – integer
Note the following to establish connectivity between Python andMYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named Library.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those books
which are priced greater than 250rs.
Statement 3- to read the complete result of the query (records of books priced
greater than 250rs.) into the object named content from the table book.
import mysql.connector as ms
def book_data():

Page-12
con1=ms.connect(host="localhost", user="root",password="tiger",
database="library")
mycursor= #Statement 1
print("Books priced greater than rs.250 are :")
_______________________ #Statement 2
content = #Statement 3
for i in content:
print(i)
print()

33. Write differences in the file opening mode “a” and “w”? 5
Abhisar is making a software on “Countries & their Capitals” in which various
records are to be stored/retrieved in CAPITAL.CSV data file. Write a python program
that defines and calls the following user defined functions
def AddNewRec(Country,Capital): A function to read and add a new record in CSV
file CAPITAL.CSV. Each record consists of the name of the country and its
capital as the fields.
def ShowRec(): A function to count and display all the records from CSV file
OR
What is the difference in write() and writelines()?
A binary file “STUDENT.DAT” has structure (admission_number, Name,
Percentage).
i. Write a function addrec() in Python that would read contents of the file
“STUDENT.DAT”
ii. Write function countrec() to display the details of those students whose
percentage is above 75. Also display number of students scoring above 75%

Page-13
SECTION E
34. Prashanth has created a database for all the items available in his shop as interiors.
Table : Interiors

No Item Name Type DateofStock Price Discount


1 Red rose Double bed 23/02/02 32000 15
2 Soft touch Baby cot 20/01/02 9000 10
3 Jerry’s home Baby cot 19/02/02 8500 10
4 Rough wood Office Table 01/01/02 20000 20
5 Comfort zone Double bed 12/01/02 15000 20
6 Jerry look Baby cot 24/02/02 7000 19
7 Lion king Office Table 20/02/02 16000 20
8 Royal tiger Sofa 22/02/02 30000 25
9 Park sitting Sofa 13/12/01 9000 15
10 Dine Paradise Dining Table 19/02/02 11000 15
11 White Wood Double bed 23/03/03 20000 20
12 James 007 Sofa 20/02/03 15000 15

Based on the above data given answer the following queries.


i. Define Degree? Write the degree of table Interior
ii. If NO is the primary key in the above table, which can be the alternate key?
iii. Write statements to :
a. To insert a record into the table as
13 Tom Look Baby Cot 21/02/03 7000 10
b. To increase the price by 1000 to all the items whose discount is 20.
OR (Option for Part iii only)
iii. Write the statements to:
a. Delete the record of interiors whose type is ‘Office Table”
b. To modify the Price column so that it has default value as 5000.
35. Preethi Shah is learning to work with binary files in Python using a process known
pickling/ unpickling. Her teacher has given her the following incomplete code,
which is creating a binary file namely Mydata.dat and then opens, reads and
displays the content of this created file,
_______________ #fill_line1
sqlist = list( )
for k in range(10):
sqlist.append(k*k)
fout = ______________ #fill_line2A
_________________ #fill_line3
fout.close( )

Page-14
fin = _______________ #fill_line2B
___________________ #fill_line4
fin.close( )
print (“Data from file :”, mylist)

Help her complete the above code as per the instructions given below:
a. Complete fill_line1 so that required python library becomes available to the
program
b. Complete fill_line2A so that the above-mentioned binary file is opened for
writing in the file object fout
c. Similarly complete fill_line2B, which will open the same binary file for
sending in the file object fin.
d. Complete fill_line3 so that the list created in the code, namely sqlist, is
written in the open file.
e. Complete fill_line4 so that the contents of the open file in the file handle fin
are read in a list namely mylist.

Page-15

You might also like