Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Kendriya Vidyalaya Kausani

Pre-Board - I Examiantion (2022-23)


Class: XII
Subject: Computer Science (083)
Maximum Marks: 70 ____________________ Time Allowed: 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 Q35
against part c only.
8. All programming questions are to be answered using Python Language only.
SECTION - A
1. State True or False 1
“Python language is based on Object Oriented Approach of programming.”
2. Which of the following is an invalid identifier in Python? 1
(a) abc (b) 1abc (c) abc_1 (d) _abc1
3. Predict the output. 1
d = {"Hema":98, "Neha":95}
print(list(d.values()))
4. Consider the given expression: 1
not False or True and False
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
print('This is my first @ preboard exam, I will try @ my best in this @
exam.’split('’@’', 2))
6. Which of the following mode in file opening statement can be used to add more 1
records in binary file?
(a) ab+ (b) rb+ (c) wb+ (d) None of the above
7. Fill in the blank: 1
______ command is used to delete a column from the table in SQL.
(a) update (b)remove (c) alter (d)drop
8. Which of the following commands will delete the table from MYSQL database? 1
(a) DELETE TABLE
(b) DROP TABLE
(c) REMOVE TABLE
(d) ALTER TABLE
9. Which of the following statement(s) would give an error after executing the 1
following code?

1
S1="Hello All" # Statement 1
print(S) # Statement 2
S2=S1+3 # Statement 3
print(S2) # Statement 4
S3=S1+"Welcome to my class" # Statement 5
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
10. Fill in the blank: 1
_________ is a key attribute, which can serve the purpose of Primary key of a
relation in SQL.
(a) Primary Key
(b) Foreign Key
(c) Candidate Key
(d) Alternate Key
11. The correct syntax of tell() is: 1
(a) tell()
(b) fileobject.tell(n)
(c) fileobject.tell()
(d) None of these
12. Fill in the blank: 1
The SELECT statement when combined with __________ clause, returns records
in ascending order of column name.
(a) group by
(b) where
(c) order by
(d) like
13. Fill in the blank: 1
______is a communication methodology designed to transfer file from source to
destination over Internet protocol.
(a) VoIP (b) FTP (c) PPP (d)HTTP
14. What will the following expression be evaluated to in Python? 1
42+4-3**2//19-3
(a) 43.25 (b) 43.0 (c) 43 (d) 43.5
15. Which function is used to display the total of values of column from table in a 1
database?
(a) sum(*)
(b) total(*)
(c) count(*)
(d) return(*)
16. To establish a connection between Python and SQL database, connect() is 1
used. How this function can be used with?
(a) Commit function
(b) cursor function
(c) file object
(d) password
17. Assertion (A):- If the arguments in function call statement match the number and 1

2
order 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).

18. Assertion (A): Text is a file where data is in human readable form. 1
Reason (R): The data is stored where internal translation take place.

SECTION B
19. Aruna has written a code to find the sum of even and odd elements from first 10 2
natural numbers. Her code is having errors. Rewrite the correct code and
underline the corrections made.

Def eveodd()
sume=0
sumo=0
for i in range(1, 11):
if i%2=0:
sum+=sume
else
sum=+sumo
print(“The sum of even numbers is:”, sume)
print(“The sum of odd numbers is:”, sumo)

20. Write two points of difference between Bus and Star Topology. Switching. 2
OR
Write two points of difference between XML and HTML.
21. (a) Given is a Python string declaration: 1

name="ComputerSciencewithPython"
print(name[3:14:2])
1
(b) Write the output of the code given below:
result = {x: x**x for x in range(4)}
print(result)

22. Explain the use of ‘Candidate key’ in a Relational Database Management System. 2
Give example to support your answer.

23. (a) Write the full forms of the following: 2

(i) TCP/IP (ii) WAN

(b) What is the use of Repeaters?


24. Predict the output of the Python code given below: 2

def Sum(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1

3
lst= [20,25,24,34,35]
for C in range (4,0,-1):
A=lst[C]
B=lst[C-1]
print(Sum(A,B),'#', end=' ')

OR
Predict the output of the Python code given below:

tuple1 = (10,20,30,40,50,60)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%3==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
25. Differentiate between count(ALL) and count(DISTINCT) functions in SQL with 2
appropriate example.
OR
Categorize the following commands as DDL or DML:
CREATE, DELETE,ALTER, INSERT
SECTION C
26. (a) Consider the following tables – Sales and Item: 1+2
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;

(b) Write the output of the queries (i) to (iv) based on the table, TABLE:
EMPLOYEE
TABLE: EMPLOYEE
EMPNO NAME DATE_OF_ SALARY CITY
JOINING
5001 SUMIT SINGH 2012-05-24 55000 JAIPUR
5002 ASHOK 2015-10-25 65000 DELHI

4
SHARMA
5003 VIJAY SINGH 2009-09-09 85000 JAIPUR
5004 RAKESH VERMA 2020-12-21 60000 AGRA
5006 RAMESH 2011-01-22 72000 DELHI
KUMAR

(a) SELECT AVG(SALARY) FROM EMPLOYEE WHERE CITY LIKE ‘%R’;


(b) SELECT COUNT(*) FROM EMPLOYEE
WHERE DATE_OF_JOINING BETWEEN ‘2011-01-01’ AND ‘2020-12-21’;
(c) SELECT DISTINCT CITY FROM EMPLOYEE WHERE SALARY >65000;
(d) SELECT CITY, SUM(SALARY) FROM EMPLOYEE GROUP BY CITY;

27. Write a method COUNTLINES() in Python to read lines from text file ‘MYFILE.TXT’ 3
and display the lines which are not starting with an alphabet “P”.
Example:

If the file content is as follows:

Peacock is our national bird.


We wish for everyone’s well being.
Integrity has important role in life.

The COUNTLINES() function should display the output as:

The number of lines not starting with an alphabet: 1

OR

Write a function MYCount() in Python, which should read each character of a


text file “TEST.TXT” and then count and display the count of occurrence of
alphabets M and Y individually (including small cases m and y too).

Example:

If the file content is as follows:

Today is a my first day in Delhi.


My favourite fruit is mango.
It is mentioned on our websites.

The MYCount() function should display the output as:


M or m: 4
Y or y : 4
28. (a) Write the outputs of the SQL queries (a) to (d) based on the relations SPORTS 3
and WINNER given below:

5
Table: SPORTS
SCODE NAME CITY COACH
S101 KARATE AGRA KARAN
S102 SQUASH DELHI ANKITA
S103 SWIMMING LUCKNOW AJAY
S104 TENNIS DELHI MUKESH

Table: WINNER
STUDENTN NAME SCODE MEDAL
O
11 AJAY S103 BRONZE
KUMAR
12 DINESH S101 GOLD
SHARMA
14 ASHOK S102 GOLD
KUMAR
15 RUPESH S101 SILVER
16 MOHIT S104 SILVER

(a) To display detail of all the sports conducted in Delhi and Agra.
(b) To display the detail of students who won medals in descending order of
their names.
(c) To display the student’s name with their game name who won gold
medal.
(d) To display medal name with total number of medals won by the students.

(b) Write the command to view the structure of a table in SQL.

29. Write a function NEGATIVE_LIST(LST), where L is the list of elements passed as 3


argument to the function. The function returns another list named ‘negativelist’
that stores the negative Elements of LST.

For example:

If LST contains [-21,20,-14,0,11,-33,86]

The negativelist will have - [-21,-14,-33]

30. Sumit has created a list containing marks of 10 students. Write a program, with 3
separate user defined function to perform the following operation:

6
PUSH()- Traverse the content of the List and push all the odd marks into the
stack.

POP()- Pop and display the content of the stack.


Example: If the content of the tuple is as follows:
T=(87, 98, 65, 21, 54, 78, 59, 64, 32, 49)
Then the output of the code should be: 49 59 21 65 87
OR
Write a function in Python, Push(BItem) where , BItem is a dictionary containing
the details of bakery items– {Bname:price}.
The function should push the names of those items in the stack who have price
less than 50.
For example:
If the dictionary contains the following data:
Bitem={"Bread":40,"Cake":250,"Muffins":80,"Biscuits":25}

The stack should contain


Bread
Biscuits
SECTION - D

7
31 IFC University is setting up its academic blocks at Bhubneshwar and is planning
to set up a network. The University has 3 academic blocks and one Human
Resource Centre as shown in the diagram below:

LAW

Center to

Center distances between various blocks/center is as follows:


Law Block to business Block 40m
Law block to Technology Block 80m
Law Block to HR center 105m
Business Block to technology Block 30m
Business Block to HR Centre 75m
Technology block to HR Centre 25m

Number of computers in each of the blocks/Center is as follows:


Law Block 15
Technology Block 40
HR BlockHR Centre 115
Business Block 25

Answer the following questions: BUSINESS


TECHNOLOGY
a) Suggest the most suitable place (i.e., Block/Center) to install the server of
this University with a suitable reason. 1
b) Suggest an ideal layout for connecting these blocks/centers with a wired
connectivity.
c) Which device will you suggest to be placed/installed in each of these 1
blocks/centers to efficiently connect all the computers within these
blocks/centers. 1
d) The university is planning to connect its admission office in Chennai, which
is more than 1500 km from university. Which type of network out of LAN, 1
MAN, or WAN will be formed? Justify your answer.
e) Suggest the best wired medium out of following to connect the 3 academic 1
blocks.
(i) Optical fibre (ii)Ethernet cable (iii) Twisted cables (iv) Radiowave
32. (a) Write the output of the code given below: 2+3
def add (b , p):
r = b ** p
return r
def divide(a):
a = add(a, 2)
return a
n = 6
result = divide(n)
print (result)

8
(b) The given program is used to connect with MySQL abd show the name of
the all the record from the table “stmaster” from the database “oraclenk”. You
are required to complete the statements so that the code can be executed
properly.

import _____.connector__pymysql # to import required module using an


object of the connection
dbcon=pymysql._____________(host=”localhost”, user=”root”,
________=”sia@1928”) # to write the password argument
if dbcon.isconnected()==False
print(“Error in establishing connection:”)
cur=dbcon.______________() #to execute the query
query=”select * from stmaster”
cur.execute(_________)
resultset=cur.fetchmany(3)
for row in resultset:
print(row)
dbcon.______() # to close the connection
OR
(a) Predict the output of the code given below:
s="Hello2everyone"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)

(b) The code given below reads the following record from the table named
employee and displays only those records who have salary greater than
53500:
Empcode – integer
EmpName – string
EmpSalary – integer

Note the following to establish connectivity between Python and MYSQL:


• Username is root
• Password is root@123
• The table exists in a MYSQL database named management.

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 employees
whose salary are greater than 53500.
Statement 3- to read the complete result of the query (records whose
salary are greater than 53500) into the object named data, from the table

9
employee in the database.

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root",
password="root@123", database="management")
mycursor=_______________ #Statement 1
print("Employees with salary greater than 53500 are : ")
_________________________ #Statement2
data=__________________ #Statement 3
for i in data:
print(i)
print()
33. What is the need of using a csv file for permanent storage? Write a Program in 5
Python that defines and calls the following user defined functions:

(i) ADDDATA() – To accept and add data of an employee to a CSV file


‘item.csv’. Each record consists of a list with field elements as itemid,
itemname and itemsupplier to store item id, itemname and item supplier
respectively.
(ii) COUNTRECORD() – To count the number of records present in the CSV file
named ‘item.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:
(i) adddata() – To accept and add data of a student to a CSV
file ‘student.csv’. Each record consists of a list with field elements
as srl, sname and smarks to store student roll no., student
name and student marks respectively.
(ii) searchdata()- To display the records of the students whose marks
more than 90.
SECTION E
34. Neha creates a table FURNITURE with a set of records to maintain the records 1+1+2
of furniture purchased by her. She has entered the 7 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 30-Dec-2016 12000 3
6
T006 Console Table 17-Nov2019 15000 12
B006 Bunk Bed 01-Jan-2021 28000 14

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

10
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 iii only )


(iii) Write the statements to:
(a) Delete the record of furniture whose price is less than 20000. division.
(b) Add a column WOOD varchar with 20 characters.

35. Write a python program to create binary file dvd.dat and write 5 records in it 4
DVD id, DVD name, qty, price Display those DVD details whose DVD price
more than 25.

________________________________xxxxxxxxxxxxxxxxxxxxxxxx____________________________

11

You might also like