Computer Science Pre-Board I (2022-23)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

KENDRIYA VIDYALAYA SANGATHAN

GUWHATI REGION
Pre – Board Examination: 2022-23
SET – I
Class: XII
SUBJECT: COMPUTER SCIENCE (083)
TIME: 03:00 HRS. MM: 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 3
only.
8. All programming questions are to be answered using Python Language only.

SECTION – A
1. State True or False
1
“Python language is Cross platform language.”
2. Which of the following is an invalid identifier in Python? 1
(a) Max_marks (b) Max–marks (c) Maxmarks (d) _Max_Marks
3. Predict the output. 1
marks = {"Ashok":98.6, "Ramesh":95.5}
print(list(marks.keys()))

(a) ‘Ashok’, ‘Ramesh’


(b) 98.6, 95.5
(c) [‘Ashok’,’Ramesh’]
(d) (‘Ashok’,’Ramesh’)
4. Consider the given expression: 1
not True and False or 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. Write the output:- 1
myTuple = ("John", "Peter", "Vicky")
x = "#".join(myTuple)
print(x)
(a) #John#Peter#Vicky
(b) John#Peter#Vicky
(c) John#Peter#Vicky#
(d) #John#Peter#Vicky#
6. Which of the following mode in file opening statement results or generates an error if 1
the file does not exist?
(a) r+ (b) a+ (c) w+ (d) None of the above
7. Fill in the blank: 1
______ command is used to ADD a column in a table in SQL.
(a) update (b)remove (c) alter (d)drop
8. Which of the following is a DML command? 1
(a) CREATE (b) ALTER (c) INSERT (d) DROP
1|Page
9. Which of the following statement(s) would give an error after executing the following 1
code?
S="Welcome to my python program" # Statement 1
print(S) # Statement 2
S="Python is Object Oriented programming" # Statement 3
S= S * “5” # Statement 4
S=S+"Thank you" # Statement 5
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
10. Fill in the blank: 1
_________ is a non-key attribute, whose values are derived from the primary key of
some other table.
(a) Foreign Key
(b) Primary Key
(c) Candidate Key
(d) Alternate Key
11. Which SQL keyword is used to retrieve only unique values? 1
(a) DISTINCTIVE (b) UNIQUE (c) DISTINCT (d) DIFFEREN
12. The correct syntax of seek() is: 1
(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
13. Fill in the blank: 1
______is a communication methodology designed to deliver electronic mail (E-mail)
over the internet.
.
(a) VoIP (b) HTTP (c) PPP (d) SMTP
14. What will the following expression be evaluated to in Python? 1
print(2**3 + (5 + 6)**(1 + 1))
(a) 129 (b)8 (c) 121 (d) None
15. Which function is used to display the total number of records from a table in a 1
database?
(a) sum(*)
(b) total(*)
(c) count(*)
(d) return(*)
16. Which of the following function is used to established connection between Python and 1
MySQL database –
(a) connection() (b) connect() (c) Connect() (d) None
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
Assertion (A): A binary file stores the data in the same way as as stored in the memory. 1
17.
Reason (R): Binary file in python does not have line delimiter.
Assertion (A):- If the arguments in a function call statement match the number and
order of arguments as defined in the function definition, such arguments are called
18. positional arguments. 1
Reasoning (R):- During a function call, the argument list first contains default
argument(s) followed by positional argument(s).
2|Page
SECTION – B
Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
Num=int(rawinput("Number:"))
sum=0
for i in range(10,Num,3)
19. sum+=1 2
if i%2=0:
print(i*2)
else:
print(i*3)
print (Sum)
Write two points of difference between LAN & WAN.
20. OR 2
Write two points of difference between XML and HTML.
(a) Given is a Python string declaration:
str="CBSE Examination@2022"
Write the output of: print(str[-1:-15:-2])

21. (b) Write the output of the code given below: 2


d = {"name": "Akash", "age": 16}
d['age'] = 27
d['city'] = "New Delhi"
print(d.items())
Explain the use of ‘Primary Key’ in a Relational Database Management System. Give
22. 2
example to support your answer.
(a) Expand the following terms: SMTP, FTP
23. 2
(b) What do you mean by MODEM?
Predict output of the following code fragment –
def Change(P ,Q=30):
P=P+Q
Q=P-Q
print(P,"#",Q)
return(P)
R=150
S=100
R=Change(R,S)
print(R,"#",S)
24. S=Change(S) 2
OR
Predict output of the following code fragment –
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)
Differentiate between count(column_name) and count(*) functions in SQL with
appropriate example.
25. OR 2
Categorize the following commands as DDL or DML:
SELECT, UPDATE, ALTER, DROP
3|Page
SECTION – C
(a) Consider the following tables – Sales and Item:
Table: Sales
SCode SName SCITY
S01 HITESH DELHI
S02 SANDEEP MUMBAI
S03 MAHESH BANGALORE

Table: Item
SCode IPRICE ICity
S01 1200 Delhi
S02 2500 Mumbai
S01 3200 Maharashtra

What will be the output of the following statement?

SELECT SNAME,SCITY,IPRICE FROM sales, Item where SCITY=”Delhi” and Sales.SCode


=Item.SCode;
1+
26. (b) Write the output of the queries (i) to (iv) based on the table, TABLE: EMPLOYEE 2=
3
TABLE: EMPLOYEE
EMPNO NAME DATE_OF_ JOINING SALARY CITY
5001 SUMIT SINGH 2012-05-24 55000 JAIPUR
5002 ASHOK SHARMA 2015-10-25 65000 DELHI
5003 VIJAY SINGH 2009-09-09 85000 JAIPUR
5004 RAKESH VERMA 2020-12-21 60000 AGRA
5006 RAMESH KUMAR 2011-01-22 72000 DELHI
(i) SELECT AVG(SALARY) FROM EMPLOYEE WHERE CITY LIKE ‘%R’;
(ii) SELECT COUNT(*) FROM EMPLOYEE
WHERE DATE_OF_JOINING BETWEEN ‘2011-01-01’ AND ‘2020-12-21’;
(iii) SELECT DISTINCT CITY FROM EMPLOYEE WHERE SALARY >65000;
(iv) SELECT CITY, SUM(SALARY) FROM EMPLOYEE GROUP BY CITY;

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.
OR
Write a function RevText() to read a text file "Story.txt" and Print only word starting
27. with 'I' in reverse order. 3
Example:
If value in text file is:
INDIA IS MY COUNTRY
Output will be: AIDNI SI MY COUNTRY.
(a) Consider the following tables ACTIVITY and COACH.
2+
Write SQL commands for the statements (i) to (iv) and give the The outputs for the SQL
28. 1=
queries (v) to (viii) –
3
Table: ACTIVITY

4|Page
ACode ActivityName ParticipantsNum PrizeMoney ScheduleDate
1001 Relay 100X4 16 10000 23-Jan-2004
1002 High Jump 10 12000 12-Dec-2003
1003 Shot Put 12 8000 14-Feb-2004
1005 Long Jump 12 9000 01-Jan-2004
1008 Discuss Throw 10 15000 19-Mar-2004

Table: COACH
PCode Name ACode
1 Ahmed Hussain 1001
2 Ravinder 1008
3 Janila 1001
4 Naaz 1003

(i) To display the name of all activities with their Acodes in descending order.
(ii) To display sum of prizemoney for each of the number of participants groupings (as
shown in column ParticipantsNum 10,12,16)
(iii) To display the coach’s name and ACodes in acending order of ACode from the table
COACH.
(iv) To display the content of the Activity table whose ScheduleDate is earlier than
01/01/2004 in ascending order of ParticipantsNum.

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

Write a function SQUARE_LIST(L), where L is the list of elements passed as argument to


the function. The function returns another list named ‘SList’ that stores the Squares of
all Non-Zero Elements of L.
29. For example: 3
If L contains [9,4,0,11,0,6,0]
The SList will have - [81,16,121,36]

A list contains following record of a customer:


[Customer_name, Phone_number, City]

Write the following user defined functions to perform given operations on the stack
named ‘status’:
(i) Push_element() - To Push an object containing name and Phone number of
customers who live in Goa to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them. Also,
display “Stack Empty” when there are no elements in the stack.

For example:
30. If the lists of customer details are: 3

[“Ashok”, “9999999999”,”Goa”]
[“Avinash”, “8888888888”,”Mumbai”]
[“Mahesh”,”77777777777”,”Cochin”]
[“Rakesh”, “66666666666”,”Goa”]

The stack should contain:


[“Rakesh”,”66666666666”]
[“Ashok”,” 99999999999”]
The output should be:

5|Page
[“Rakesh”,”66666666666”]
[“Ashok”,”99999999999”]
Stack Empty

OR

Vedika has created a dictionary containing names and marks as key-value pairs
of 5 students. Write a program, with separate user-defined functions to perform the
following operations:

(i) Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.
(ii) Pop and display the content of the stack.

The dictionary should be as follows:

d={“Ramesh”:58, “Umesh”:78, “Vishal”:90, “Khushi”:60, “Ishika”:95}

Then the output will be:


Umesh Vishal Ishika
SECTION – D

Ravya Industries has set up its new center at Kaka Nagar for its office and web based
activities. The company compound has 4 buildings as shown in the diagram below:

Distance between various blocks/locations:


Harsh to Raj Building 50m
Raj to Fazz Building 60m
Fazz to Jazz Building 25m
31. Jazz to Harsh Building 170m
Harsh to Fazz Building 125m
Raj to Jazz Building 90m

Number of computers in each building are -


Harsh – 15
Raj - 150
Fazz - 15
Jazz - 25

(i) Suggest a cable layout of connections between the buildings. 1


(ii) Suggest the most suitable place (i.e. building) to house the server of this 1
organisation with a suitable reason.
(iii) Suggest the placement of the following devices with appropriate reasons: 1
a. Hub / Switch
b. Repeater

6|Page
(iv) The organisation is planning to link its sale counter situated in various parts of 1
the same city, which type of network out of LAN, MAN or WAN will be formed?
Justify your answer.
(v) Suggest a device/software to be installed in the Campus to take care of data 1
security.
(a) Write the output of the code given below:

def fun(s):
k=len(s)
m=" "
for i in range(0,k):
if s[i].isupper():
m=m+s[i].lower()
elif s[i].islower():
m=m+s[i].upper()
elif s[i].isdigit():
m=m+"O"
else:
m=m+'#'
print(m)
fun('CBSE@12@Exam')

(b) The code given below inserts the following record in the table EMP:
EmpID – integer
Name – string
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
is root
kvs 2+
32.
KVS. 3
EmpID, Name, Salary) 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 EMP.
Statement 3- to add the record permanently in the database

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root",password="kvs", database="KVS")
mycursor=_________________ #Statement 1
eno=int(input("Enter Employee ID : "))
name=input("Enter name : ")
sal=int(input("Enter Salary : "))
querry="insert into EMP values({},'{}',{})".format(eno,name,sal)
______________________ # Statement 2
______________________ # Statement 3
print("Data Added successfully")

OR

7|Page
(a) Study the following program and select the possible output(s) from the options (i) to
(iv) following it.
Also, write the maximum and the minimum values that can be assigned to the
variable Y
import random
X= random.random()
Y= random.randint(0,4)
print(int(X),":",Y+int(X))
(i) 0 : 0
(ii) 1 : 6
(iii) 2 : 4
(iv) 0 : 3

(b) The code given below reads the following record from the table named student and
displays only those records who have marks greater than 75:
RollNo – integer
Name – string
Clas – integer
Marks – integer
Note the following to establish connectivity between Python and MYSQL:

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 students whose
marks are greater than 75.
Statement 3- to read the complete result of the query (records whose marks are
greater than 75) into the object named data, from the table student in the database.

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="school")
mycursor=_______________ #Statement 1
print("Students with marks greater than 75 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()

What is the advantage of using a csv file for permanent storage?


Write a Program in Python that defines and calls the following user defined functions:
(i) ADDPROD() – To accept and add data of a product to a CSV file ‘product.csv’.
Each record consists of a list with field elements as prodid, name and price to store
product id, employee name and product price respectively.
33. (ii) COUNTPROD() – To count the number of records present in the CSV file named 5
‘product.csv’.
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:

8|Page
(i) add() – To accept and add data of a to a CSV file ‘stud.csv’. Each record
consists of a list with field elements as admno, sname and per to store admission
number, student name and percentage marks respectively.
(ii) search()- To display the records of the students whose percentage is more
than 75.

SECTION – D
Rashmi creates a table FURNITURE with a set of records to maintain the records of
furniture purchased by her. She has entered the 6 records in the table. Help her to find
the answers of following questions:-
FID NAME DATE OF PURCHASE COST DISCOUNT

B001 Double Bed 03-Jan-2018 45000 10


T010 Dining Table 10-Mar-2020 51000 5
B004 Single Bed 19-Jul-2021 22000 0
C003 Long Back Chair 6 30-Dec-2016 12000 3

T006 Console Table 17-Nov2019 15000 12 1+


34. 1+
B006 Bunk Bed 01-Jan-2021 28000 14 2

1. Identify the Primay Key from the given table with justification of your answer.
2. If three more records are added and 2 more columns are added, find the degree
and cardinality of the table.
3. (i) Write SQL command to insert one more data/record to the table
(ii) Increase the price of furniture by 1000, where discount is given more than 10.
OR (Option for part 3 only )
3. Write the statements to:
(a) Delete the record of furniture whose price is less than 20000.
(b) Add a column WOOD varchar with 20 characters.
Mr. Deepak is a Python programmer. He has written a code and created a binary
file “MyFile.dat” with empid, ename and salary. The file contains 15 records.
He now has to update a record based on the employee id entered by the user and
update the salary. The updated record is then to be written in the file “temp.dat”. The
records which are not to be updated also have to be written to the file “temp.dat”. If
the employee id is not found, an appropriate message should to be displayed.
As a Python expert, help him to complete the following code based on the
requirement given above:

import _______ #Statement 1


def update_rec():
rec={}
35. 4
fin=open("MyFile.dat","rb")
fout=open("_____________") #Statement 2
found=False
eid=int(input("Enter employee id to update salary : "))
while True:
try:
rec=______________ #Statement 3
if rec["empid"]==eid:
found=True
rec["salary"]=int(input("Enter new salary : "))
pickle.____________ #Statement 4
else:
9|Page
pickle.dump(rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has been updated.")
else:
print("No employee with such id is not found")
fin.close()
fout.close()

(i) Which module should be imported in the program? (Statement 1)


(ii) Write the correct statement required to open a temporary file named temp.dat.
(Statement 2)
(iii) Which statement should Deepak fill in Statement 3 to read the data from the binary
file, record.dat and in Statement 4 to write the updated data in the file, temp.dat?

######################

10 | P a g e

You might also like