Class 12th - QuestionBank - ComputerScience
Class 12th - QuestionBank - ComputerScience
SECTION A
1. c. a b c=100 200 300 1
2. (b) ** 1
3. c) Error 1
5. (d) ("f","o","obar") 1
7. (c) references 1
9. (a) start(10) 1
SECTION B
. OR
21 (a) typeerror 1+1
.
(b) 30
22 Referential integrity refers to the relationship between tables. Because each 1+1
. table in a database must have a primary key, this primary key can appear in
other tables because of its relationship to data within those tables. When a
primary key from one table appears in another table, it is called a foreign key .
25 2
.
Find output:
(a)
PID PNAME QTY PRIC COMPAN SUPCO SUPCO SNAM CITY
E Y DE DE E
101 DIGITA 120 1200 RENBIX S01 S01 GET KOLKA
L 0 ALL TA
CAMER IN
A 14X
102 DIGITA 100 2200 DIGI POP S02 S02 DIGI CHEN
L PAD 0 BUSY NAI
11I GROU
P
104 PENDRI 500 1100 STOREKI S01 S01 GET KOLKA
VE NG ALL TA
16GB IN
106 LED 70 2800 DISPEXPE S02 S02 DIGI CHEN
SCREE 0 RTS BUSY NAI
N 32 GROU
P
105 CAR 60 1200 MOVEON SO3 SO3 EASY DELHI
GPS 0 MARK
SYSTE ET
M CORP
(b)
PID PNAME QTY PRICE COMPANY SUPCOD SNAME CITY
E
101 DIGITAL 120 1200 RENBIX S01 GET KOLKAT
CAMERA 0 ALL IN A
14X
102 DIGITAL 100 2200 DIGI POP S02 DIGI CHENN
PAD 11I 0 BUSY AI
GROUP
104 PENDRIV 500 1100 STOREKIN S01 GET KOLKAT
E 16GB G ALL IN A
106 LED 70 2800 DISPEXPER S02 DIGI CHENN
SCREEN 0 TS BUSY AI
32 GROUP
105 CAR GPS 60 1200 MOVEON SO3 EASY DELHI
SYSTEM 0 MARKE
T
CORP
SECTION C
26 (a) import mysqlconnector as myc 1
mycon=myc.connect(host=”localhost” user=”Admin” passwd=”Admin123”
databse=”System”) 0.5 X4
(b) Write the output of the queries (a) to (d) based on the table, Staff given
below:
Table: Staff
(a) 5.66
(b) 12-01-2006
(c) 3 Christina 15-11-2009 Sales F 12
7 habeena 16-08-2011 Sales F 10
(d) Dima 03-05-2016
Danish 11-09-2013
27. f1=open(“TEXT1.TXT”) 3
f2=open(“TEXT2.TXT”,”w”)
data=f1.read().split()
for word in data:
if word[0] not in “AEIOU”:
f2.write(word, “ “)
f1.close()
f2.close()
OR
f1=open(“TEXT1.TXT”)
data=f1.readlines()
for line in data:
if line.strip()[-1]==”a”:
print(line)
f1.close()
28. Create table Employee(Empid int(5) primary key, Empname char(25) not null, 3
Design char(15) unique , Salary float, DOB date);
29. def merge_tuple(t1,t2): 3
t3=( )
if len(t1)==len(t2):
for i in range(len(t1)):
t3[i]=t1[i]+t2[i]
return t3
return -1
def pop(stack):
if stack==[ ]:
print(“underflow”)
else:
print(stack.pop())
OR
def push(l, stack):
for ele in l:
if ele<0:
stack.append(ele)
def pop(stack):
if stack==[ ]:
print(“underflow”)
else:
print(stack.pop())
SECTION
D
31. (a) Star topology , optical fibre or coaxial
(b) S wing as it has maximum no. of computers resulting in maximum
internal traffic as per 80:20 rule
(c) hub/Switch should be place in all the wings
(d) WiFi Router OR WiMax OR RF Router OR Wireless Modem OR
RFTransmitter
(e) any suitable layout
32. (a) 15 20 15 2+3
Write a program to
(a)
(b) f=open(“data.csv”,”r”)
data=csv.reader()
If row[2]==Cls:
print(row)
OR
I.
import pickle
def CreateEmp():
f1=open("emp.dat",'wb')
eid=input("Enter E. Id")
ename=input("Enter Name")
designation=input("Enter Designation")
salary=int(input("Enter Salary"))
l=[eid,ename,designation,salary]
pickle.dump(l,f1)
f1.close()
II.
import pickle
def display():
f2=open("emp.dat","rb")
while True:
try:
rec=pickle.load(f2)
print(rec['eid'],rec['ename'],rec['designation'],rec['salary'])
except EOFError:
break
f2.close()
SECTION E
34 (a) degree = 9 cardinality = 20 1+1+2
(b) degree = 8 cardinality = 28
(c) (i) Select Name, fare, f_date from passenger p, flight f where p.fno=f.fno and
start=”DELHI”;
(ii) delete from flight where end=”MUMBAI”;
OR
(c) Create table traveller as select * from passenger;
35. I. d) import 5
II. c) csvwriter
III. d) rec
IV. b) customer.csv
V. d) rec
Class: XII Session: 2022-23
Computer Science (083)
Sample Question Paper (Theory)
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. Which of the following is an invalid statement? 1
a. abc=1,000,000 c. a b c=100 200 300
b. a, b, c= 100,200,300 d. a=b=c=100
2. Which of the following operators has the highest precedence? 1
(a) << (b) ** (c)% (d)and
3. What will be the output of the following Python code snippet? 1
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
a) True
b) False
c) Error
d) None
4. What will be the value of the given expression? 1
3+3.00, 3**3.0
(a) (6.0, 27.0)
(b) (6.0, 9.00)
(c) (6,27)
(d) [6.0,27.0]
(e) [6,27]
5. Select the correct output of the code: 1
a = "foobar"
a = a.partition("o")
(a) ["fo","","bar"]
(b) ["f","oo","bar"]
(c) ["f","o","bar"]
(d) ("f","o","obar")
6. If a text file is opened in w+ mode, then what is the initial position of file 1
pointer/cursor?
8. Which of the following commands will change the datatype of the table in 1
MYSQL?
(a) DELETE TABLE
(b) DROP TABLE
(c) REMOVE TABLE
(d) ALTER TABLE
9. For a user defined function with header 1
def start (x, y, z=10),
Which of the following function call statements will generate an
error?
16. Name the method which is used for displaying only one resultset. 1
(a) fetchmany (b) fetchno (c) fetchall (d) fetchone
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. Both A and R are false.
d. A is True but R is False
e. A is false but R is True
18. Assertion (A): Local Variables are accessible only within a function or block in 1
which it is declared
Reason (R): Global variables are accessible in the whole program.
SECTION B
20. Write two points of difference between Circuit Switching and Packet Switching. 2
OR
25. 2
(a) Find the Degree and Cardinality of the Cartesian product of the
Supplier and Product relations.
(b) Identify the foreign key in the given tables, also mention in which table
it is appearing as a foreign key?
OR
Find output:
(a) select *from product p, supplier s where p.supcode=s.supcode;
(b) select *from product natural join supplier;
SECTION C
26 (a) Create the connection of Python with MYSQL, in which (1) 1+2
User=Admin Password= Admin2123 Database Name=System
(b) Write the output of the queries (a) to (d) based on the table, Staff given
below:
Table: Staff
OR
Write a Python program to count all the line having 'a' as last character.
28. Dileep has to create a database named Company in MYSQL. 3
He now needs to create a table named Employee in the database to store the
records of employees in the company. The table Employee has the following
structure:
Table: Employee
29. Write a function merge_tuple(t1,t2), where t1 and t2 are the tuples of elements 3
passed as argument to the function. The function returns another tuple named that
stores the sum of consecutive element of t1 and t2, only if they are of same length
else return -1
For example:
T1=(1,2,3,4)
T2=(5,6,7,8)
Then function should return
(6,8,10,12)
And if
T1=(1,2,3)
T2=(5,6,7,8)
Then function should return
-1
30. Rajiv has created a dictionary containing employee names and their salaries as 3
key value pairs of 6 employees.
Write a program, with separate user defined functions to perform the following
operations:
● Push the keys (employee name) of the dictionary into a stack, where the
corresponding value (salary) is less than 85000.
● Pop and display the content of the stack.
For example:
If the sample content of the dictionary is as follows:
OR
Aruna has a list containing temperatures of 10 cities. You need to help her create
a program with separate user defined functions to perform the following
operations based on this list.
● Traverse the content of the list and push the negative temperatures into a stack.
● Pop and display the content of the stack.
For Example:
If the sample Content of the list is as follows:
T=[-9, 3, 31, -6, 12, 19, -2, 15, -5, 38]
Sample Output of the code should be:
-5 -2 -6 -9
SECTION
D
31. Excel Public School, Coimbatore is setting up the network between its 5
different
wings of school campus. There are 4 wings namely SENIOR(S), JUNIOR
(J),
ADMIN (A) and HOSTEL (H).
x = 10
def localvar():
global x
x+=5
print(x, end=' ')
print(x+5, end=' ')
localvar()
print(x, end=' ')
____________________ #statement 1
dataBase = mysql.connector.connect(
host ="localhost",
user ="user",
passwd ="password",
database = "gfg"
)
# creating table
studentRecord = """CREATE TABLE STUDENT (
NAME VARCHAR(20) NOT NULL,
BRANCH VARCHAR(50),
ROLL INT NOT NULL,
SECTION VARCHAR(5),
AGE INT
)"""
# table created
cursorObject.________________________ #statement 3
OR
I.Write a user defined function CreateEmp() to input data for a record and add to
emp.dat.
SECTION
E
34 Write SQL queries for (a) to (d) based on the tables PASSENGER and 1+1+2
FLIGHT given below:
(a) what will be the degree and cardinality of the resulting relation after Cartesian
product of above relations?
(b) what will be the degree and cardinality of the resulting flight after addition of
two rows and deletion of one column?
(c) (i) Write a query to display the NAME, corresponding FARE and F_DATE
of all PASSENGERS who have a flight to START from DELHI.
(ii) Write a query to delete the records of flights which end at Mumbai.
OR
(c) create a new table traveller having same fields and tuples as passenger.
35. Sudev, a student of class 12th, is learning CSV File Module in Python. During 5
examination, he has been assigned an incomplete python code to create a CSV file
‘customer.csv’. Help him in completing the code which creates the desired CSV
file.
I. Identify suitable code for the blank space in line marked as Statement-
a) include
b) add
c) Import
d) import
II. Identify the missing code for the blank space in line marked as Statement-2.
a) Customer
b) reader
c) csvwriter
d) writer
III. Identify the argument name for the blank space in line marked as Statement-3?
a) Row
b) Rec
c) row
d) rec
IV. Identify the missing file name for the blank space in line marked as Statement-
4?
a) customer
b) customer.csv
c) customer.txt
d) customer.dat
V. Identify the object name for the blank space in line marked as Statement-5?
a) i
b) Rec
c) row
d) rec
KENDRIYA VIDYALAYA SANGATHAN – MUMBAI REGION
Sample Question Paper
Class: XII
Subject: Computer Science Max. Marks: 70
Blue Print
Page 1 of 35
KENDRIYA VIDYALAYA SANGATHAN – MUMBAI REGION
Sample Question Paper
Class: XII Time: 3 Hours
Subject: Computer Science Max. Marks: 70
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 1 mark each.
4. Section B has 7 very short answer type questions carrying 2 marks each.
5. Section C has 5 short answer type questions carrying 3 marks each.
6. Section D has 3 long answer type questions carrying 5 marks each.
7. Section E has 2 long answer type questions carrying 4 marks each.
8. Internal choices are given in few questions.
9. All programming questions are to be answered using PYTHON language only.
SECTION – A
1 Identify the name(s) from the following that cannot be used as identifiers in 1
Python:
asaword22, 22ndyear, date26-10-2022, _my_file_2
2 Name the datatype for the following: 1
a. ‘True’
b. 2.46E-2
3 Consider the following dictionary: 1
machine = {‘id’:1001, ‘name’:’UPS’, ‘capacity’:5000, ‘rate’:15000.00}
Write a statement to change the capacity to 4500.
4 What will be the result of following expression: 1
10>12 and “a”+1<55
a. True
b. False
c. Error
d. None
5 What will be the output of the following: 1
str = “Cricket World Cup in Australia”
str2 = str[:7] + ” “ + str[18:] + “.”
print(str2)
6 Which of the file opening mode will not create a new file if file does not exist: 1
a. r
b. w
c. a
d. There is not such file opening mode
7 Fill in the blank: 1
Command used to remove a column/attribute from the table/relation is _________.
a. Update
b. Drop
c. Alter
d. Remove
Page 2 of 35
8 Shridharan created a database namely work. Now he wants to create a table in 1
it. For this he needs to open the database he created. Write command to open
the database that is created by Shridharan.
9 What will be the output of the following code: 1
address = ‘42/B/III, Van-Vihar Colony, Nagpur’
str = address.replace(‘/’,’@’)
print(address)
10 Fill in the blank: 1
The attribute which is a candidate key but not a primary key is known as
_______________________.
11 Which of the following gives the result as string when applied to text file in 1
Python:
a. read()
b. readline()
c. readlines()
d. get()
12 When following command is run the result yielded 20 rows: 1
SELECT * FROM Clock;
But when following command is run; it yielded 17 rows only:
SELECT name FROM Clock;
Can you state the reason for the difference?
13 Which of the following is used for remote login: 1
a. VoIP
b. HTTP
c. IMAP
d. TELNET
14 What will be the output of the following statement: 1
print(30/5+(16+6))
15 Rajiv ran following two commands: 1
SELECT count(commission) FROM Employee;
SELECT count(*) FROM Employee;
Output of first command is 8 where output of second command is 14. What is
the reason for the difference?
16 After executing any DML command from Python in Python-Mysql connectivity, 1
following is necessary to execute in order to make the changes permanent in
MySQL:
a. save()
b. store()
c. commit()
d. update()
Questions 17 and 18 are ASSERTION (A) and REASONING ® based questions. Mark the
correct choice as
a. Both A and R are true and R is the correct explanation of A.
b. Both A and R are true and 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 3 of 35
17 Assertion (A): Inside a function if we make changes in a string it will reflect 1
back to the original string.
Reason (R): String is an immutable datatype and it is called by value.
18 Assertion (A): In CSV file there is a blank line after every record. 1
Reason (R): Default value of newline is ‘\n’ in open() statement used with
csv file.
SECTION – B
19 Following code is having some errors. Rewrite the code after correcting and 2
underlining each correction:
x == 20
def printme():
y = x + 10
sum = 0
for i in range(x,y)
if i%3=0:
sum=sum+i+1
Elseif:
sum += 2
return(sum)
20 Write one advantage and one disadvantage of using Fiber Optic Cable. 2
OR
Write two differences between Circuit Switching and Packet Switching.
21 What will be the output of the following code: 2
sub = “083 Comp. Sc. & 065 Info. Prac.”
n = len(sub)
s=’’
for i in range(n):
if sub[i].isupper():
s = s + sub[i].lower()
elif sub[i].islower():
s = s + sub[i]
elif sub[i].isdigit():
s = s + ‘x’
elif sub[i].isspace():
pass
else:
s = s + ‘!’
print(s)
22 Define Foreign Key. Identify foreign key from the following tables: 2
Table: Bank_Account
Acctno Name BCode Type
1001 Amrita A2 Savings
1002 Parthodas A3 Current
1005 Miraben A2 Current
Table: Branch
Page 4 of 35
Code City
A1 Delhi
A2 Mumbai
A3 Nagpur
23 a. What is the full form of SMTP and HTTP? 1
b. What is the use of POP3? 1
24 What will be the output of the following code: 2
def Call4Change():
for i in range(len(lst)):
if lst[i]%2==0:
lst[i]+=1
elif lst[i]%3==0:
lst[i]+=2
elif lst[i]%5==0:
lst[i]+=4
else:
lst[i]=0
lst = [1, 2, 9, 5, 12, 6, 7, 3, 10, 8, 11, 4]
Call4Change()
print(lst)
OR
What will be the output of the following code:
def Value2New(M, N=10):
M = M + N
N = N*2
if N%10==0:
N=N/5
return(M,N)
P,Q = Value2New(100,20)
print(P,’#’,Q)
P,Q = Value2New(50)
print(P,’#’,Q)
25 Name the SQL function that will be used in following situations:
a. To find the average salary paid to employees. ½
b. To find the month in which an employee is hired. ½
c. To find position of a substring in customer name. ½
d. To find 40% of totalmarks rounded to 2 decimal places. ½
OR
Consider the following tables and write queries for a and b:
Table: Bank_Account
Acctno Name BCode Type
1001 Amrita A2 Savings
1002 Parthodas A3 Current
1005 Miraben A2 Current
Page 5 of 35
Table: Branch
Code City
A1 Delhi
A2 Mumbai
A3 Nagpur
a. To list Acctno, Name and City of those accounts whose Account Type is
Current. 1
b. To display Acctno and Name of those accounts whose Code is A2. 1
SECTION – C
26 Consider the following tables and answer the questions a and b:
Table: Garment
GCode GName Rate Qty CCode
G101 Saree 1250 100 C03
G102 Lehanga 2000 100 C02
G103 Plazzo 750 105 C02
G104 Suit 2000 250 C01
G105 Patiala 1850 105 C01
Table: Cloth
CCode CName
C01 Polyester
C02 Cotton
C03 Silk
C04 Cotton-
Polyester
a. What will be output of the following command:
1
SELECT * FROM GARMENT NATURAL JOIN CLOTH;
b. What will be the output of following commands:
i. SELECT DISTINCT QTY FROM GARMENT;
½
ii. SELECT SUM(QTY) FROM GARMENT GROUP BY CCODE
½
HAVING COUNT(*)>1;
½
iii. SELECT GNAME, CNAME, RATE FROM GARMENT G,CLOTH C
WHERE G.CCODE = C.CCODE AND QTY>100;
½
iv. SELECT AVG(RATE) FROM GARMENT WHERE RATE BETWEEN
1000 AND 2000;
27 Write a function countbb() in Python, which reads the contents from a text file 3
‘article.txt’ and displays number of occurrences of words ‘bat’ and ‘ball’ (in all
possible cases) to the screen.
Example:
If the content of file article.txt is as follows:
Bat and ball games are field games played by two opposing teams. Action starts
when the defending team throws a ball at a dedicated player of the attacking
team, who tries to hit it with a bat and run between various safe areas in the
field to score runs (points). The defending team can use the ball in various
ways against the attacking team's players to force them off the field when they
are not in safe zones, and thus prevent them from further scoring. The best
Page 6 of 35
known modern bat and ball games are cricket and baseball, with common roots
in the 18th-century games played in England.
The countbb() function should display as:
Number of times bat occurs is 3
Number of times ball occurs is 5
OR
Write a function SOnly() in Python, which reads the contents from a text file
‘news.txt’ and creates another file ‘modnews.txt’. New file contains only those
lines that starts with an alphabet.
Example:
If the content of file news.txt is as follows:
This is Peter from California.
24th street is where I live.
__name__ is used in Python functions.
User defined functions is what I am presently reading.
Upon execution of function Sonly() file modnews.txt should contain:
This is Peter from California.
User defined functions is what I am presently reading.
28 Consider following tables and write queries for situation a and b. Find the output
of c and d:
Table: CLUB
CoachID CoachNam Ag Sports Dateofapp Pay Sex
e e
1 KUKREJA 35 KARATE 1996-03-27 1000 M
2 RAVINA 34 KARATE 1998-01-20 1200 F
3 KARAN 34 SQUASH 1998-02-19 2000 M
4 TARUN 33 BASKETBALL 1998-01-01 1500 M
5 ZUBIN 36 SWIMMING 1998-01-12 750 M
6 KETAKI 36 SWIMMING 1998-02-24 800 F
7 ANKITA 39 SQUASH 1998-02-20 2200 F
8 ZAREEN 37 KARATE 1998-02-22 1100 F
9 KUSH 41 SWIMMING 1998-01-13 900 M
10 SHAILYA 37 BASKETBALL 1998-02-19 1700 M
Table: COACHES
Sportsperson Sex Coach_No
AJAY M 1
SEEMA F 2
VINOD M 1
TANEJA F 3
Page 7 of 35
d. SELECT Sex, MAX(Dateofapp), MIN(Dateofapp) FROM Club GROUP ½
BY Sex;
29 Write a function SumDiv(L,x), where L is a list of integers and x is an integer; 3
passed as arguments to the function. The function returns the sum of elements
of L which are divisible by x or x+1.
For example,
If L Contains [10, 27, 12, 20, 22] and x is 5
Then function returns 42 (10+12+20)
30 A nested list contains the records of Mobiles in the following format: 3
[[modelno, name, price], [modelno, name, price], [modelno, name, price],….]
Write the following user defined functions to perform given operations on the stack
named Mobile:
a. Push operation – To push details (modelno, name, price) of those
mobiles which has price lower than 10000. Make a note that there cannot
be more than 20 elements in stack Mobile.
b. Pop operation – To pop elements from stack one by one and display
them. Also, display “Underflow” when stack becomes empty.
For example,
If the list contains
[[‘V20’, ‘Vivo 20 SE’, 18000], [‘S11’, ‘Lava S11’, 8900], [‘i88’, ‘IPro 88
SE’, 6500], [‘ip13’, ‘iPhone 13’, 125000]]
The stack should contain:
[‘i88’, ‘IPro 88 SE’, 6500]
[‘S11’, ‘Lava S11’, 8900]
The Output should be:
[‘i88’, ‘IPro 88 SE’, 6500]
[‘S11’, ‘Lava S11’, 8900]
Underflow
OR
A Dictionary Medal contains the details of schools and medals won by them in
following format {school_name:medals_won}.
Write a function Push(Medal) in Python that pushes those school names in stack
named SCHOOL which has won more than 3 medals. Maximum capacity of stack
SCHOOL is 15. Function also shows number of items pushed in stack. If number
of items exceeds 15 then it shows OVERFLOW.
For example:
If dictionary Medal contains
{‘KV1’:5, ‘KV2’:2, ‘KV3’:4, ‘KV4’:1, ‘KV5’:7}
Then stack should contain
KV5
KV3
KV1
The output should be:
Number of item pushed in stack Medal are 3
Page 8 of 35
SECTION D
31 Superior Education Society is an educational Organization. It is planning to setup
its Campus at Nagpur with its head office at Mumbai. The Nagpur Campus has
4 main buildings – ADMIN, COMMERCE, ARTS and SCIENCE.
You as a network expert have to suggest the best network related solutions for
their problems raised in a to e, keeping in mind the distances between the
buildings and other given parameters:
Page 10 of 35
elif m<=40:
print(“Half Past”,T)
elif m<=59:
print(“Quarter to”,T+1)
else:
print(“Incorrect Minutes”)
Timing(5,18)
Timing(11)
Timing(12,60)
b. The code given below reads those records from table Garment which has Qty 3
less than 50. Records in table Garments are stored with following attributes:
GCode – integer
GName – string
Rate – decimal
Qty – integer
CCode = integer
Write missing Statements (Statement 1, Statement 2 and Statement 3) to
complete the code:
import mysql.connector as mycon
cn = mycon.connect(host=’localhost’, user=’test’, password=’None’,
database=’cloth’)
cur = ______________________ #Statement 1
cur._________________________ #Staatement 2 (Create & Execute
Query)
G = ____________________ #Statement 3Read complete result of
query
print(“Required records are:”)
for i in G:
print(i)
cn.close()
33 What is the difference between CSV file and Text File? Write a program in 5
Python that defines and calls the following functions:
Insert() – To accept details of clock from the user and stores it in a csv file
‘watch.csv’. Each record of clock contains following fields – ClockID, ClockName,
YearofManf, Price. Function takes details of all clocks and stores them in file in
one go.
Delete() – To accept a ClockID and removes the record with given ClockID
from the file ‘watch.csv’. If ClockID not found then it should show a relevant
message. Before removing the record it should print the record getting removed.
OR
Give one advantage of using CSV file over Binary file. Write a program in Python 5
that defines and calls the following functions:
saving() – To accepts details of equipments from the user in following format
(ID, Name, Make, Price) and save it in a csv file ‘parts.csv’. Function saves
one record at a time.
Page 11 of 35
search() – To accept two prices and displays details of those equipments which
has price between these two values.
SECTION E
34 Mayanti just started to work for a sports academy having several branches across
India. The sports academy appoints various trainers to train various sports. She
has been given the task to maintain the data of the trainers. She has made a
table called TRAINERS in the database which has following records:
Table: TRAINER
TrainerNo Name City HireDate Salary
101 SUNAINA MUMBAI 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHANDIGARH 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 RICHA MUMBAI 1996-01-12 95000
106 MANIPRABHA CHENNAI 2001-12-12 69000
Based on the data given above answer the following questions:
a. Can City be used as Primary key for table TRAINER? Justify your answer. 1
b. What is the degree and cardinality of the table TRAINER? If we add two 1
rows and remove three rows from table TRAINER. Also if we add another
attribute in the table, what will be the degree and cardinality of the table
TRAINER will become?
c. Write statements for:
i. Insert a new record in table TRAINER with values, TrainerNo = 1
107, Name = Swastik, HireDate = 1999-01-22, Salary = 90000.
ii. Increase the salary of those Trainer having city as DELHI by 5000. 1
OR
c. Write Statements for:
i. Removes those records from table TRAINER who were hired after 1
year 2000.
ii. Add a new column Grade with datatype as Varchar and maximum 1
size as 2.
35 Tarun Nair is working under XYZ Incorporation which deals with exporting of goods
to foreign countries. To keep track of inventory he is creating a Python program
to store the information of item number and quantity in a binary file inventory.dat.
For that he has written the following code. Go through the code given and solve
problems given below:
def write(ino,qty):
F = open(____________) #Mark 2
L= _______________ #Mark 3
L.append([ino,qty])
F.close()
F=open('inventory.dat','wb')
pickle.dump(L,F)
F.close()
Page 12 of 35
def Receive(ino,qty):
F=open(“inventory.dat”,”rb”)
L=pickle.load(F)
F.close()
for i in range(len(L)):
if L[i][0] == ino:
L[i][1] += qty
F=open("inventory.dat",'wb')
pickle.dump(L,F)
________________ #Mark 4
def Sent(ino,qty):
with open(“inventory.dat”,”rb”) as F:
L=pickle.load(F)
for i in range(len(L)):
if L[i][0] == ino:
L[i][1] -= qty
with open("inventory.dat",'wb') as F:
pickle.dump(L,F)
a. Write statement to open the file at Mark 2 to read records from the file. 1
b. Write statement at Mark 3 to read the content of binary file in list L. 1
c. Write statement at Mark 4 to close the file. 1
d. Why there is no need to close the file in function Sent()? 1
**************************************************************
Page 13 of 35
KENDRIYA VIDYALAYA SANGATHAN – MUMBAI REGION
Marking Scheme
Class: XII Time: 3 Hours
Subject: Computer Science Max. Marks: 70
1 Identify the name(s) from the following that cannot be used as identifiers in Python:
asaword22, 22ndyear, date26-10-2022, _my_file_2
Answer:
22ndyear, date26-10-2022
½ mark for each correct answer
2 Name the datatype for the following:
a. ‘True’
b. 2.46E-2
Answer:
a. String or str
b. Float or Number
½ mark for each correct answer
3 Consider the following dictionary:
machine = {‘id’:1001, ‘name’:’UPS’, ‘capacity’:5000, ‘rate’:15000.00}
Write a statement to change the capacity to 4500.
Answer:
machine[‘capacity’] = 4500
1 mark for the correct answer
4 What will be the result of following expression:
10>12 and “a”+1<55
a. True
b. False
c. Error
d. None
Answer:
b. False
1 mark for the correct answer
5 What will be the output of the following:
str = “Cricket World Cup in Australia”
str2 = str[:7] + ” “ + str[18:] + “.”
print(str2)
Answer:
Cricket in Australia.
1 mark for the correct answer
6 Which of the file opening mode will not create a new file if file does not exist:
a. r
b. w
c. a
d. There is not such file opening mode
Answer:
a. R
Page 14 of 35
1 mark for the correct answer
7 Fill in the blank:
Command used to remove a column/attribute from the table/relation is _________.
a. Update
b. Drop
c. Alter
d. Remove
Answer:
c. Alter
1 mark for the correct answer
8 Shridharan created a database namely work. Now he wants to create a table in it.
For this he needs to open the database he created. Write command to open the
database that is created by Shridharan.
Answer:
Use work;
1 mark for the correct answer
½ mark if only Use is written.
9 What will be the output of the following code:
address = ‘42/B/III, Van-Vihar Colony, Nagpur’
str = address.replace(‘/’,’@’)
print(address)
Answer:
42/B/III, Van-Vihar Colony, Nagpur
1 mark for the correct answer
10 Fill in the blank:
The attribute which is a candidate key but not a primary key is known as
_______________________.
Answer:
Alternate Key
1 mark for the correct answer
11 Which of the following gives the result as string when applied to text file in Python:
a. read()
b. readline()
c. readlines()
d. get()
Answer:
a. read() and b. readline()
½ mark each for each correct answer
12 When following command is run the result yielded 20 rows:
SELECT * FROM Clock;
But when following command is run; it yielded 17 rows only:
SELECT name FROM Clock;
Can you state the reason for the difference?
Answer:
Page 15 of 35
First command displays all columns from the table Clock but second command shows only
name column. Difference between output rows is because three rows have NULL values for
name column.
1 mark for the correct answer
13 Which of the following is used for remote login:
a. VoIP
b. HTTP
c. IMAP
d. TELNET
Answer:
d. TELNET
1 mark for the correct answer
14 What will be the output of the following statement:
print(30/5+(16+6))
Answer:
28.0
1 mark for the correct answer
15 Rajiv ran following two commands:
SELECT count(commission) FROM Employee;
SELECT count(*) FROM Employee;
Output of first command is 8 where output of second command is 14. What is the
reason for the difference?
Answer:
First command counts commission column whereas second command counts rows present
in the table. Reason for difference is that there are 6 rows in tables having NULL for column
commission.
1 mark for the correct answer
16 After executing any DML command from Python in Python-Mysql connectivity, following
is necessary to execute in order to make the changes permanent in MySQL:
a. save()
b. store()
c. commit()
d. update()
Answer:
c. commit()
1 mark for the correct answer
17 Assertion (A): Inside a function if we make changes in a string it will reflect back
to the original string.
Reason (R): String is an immutable datatype and it is called by value.
Answer:
d. A is false but R is true
1 mark for the correct answer
18 Assertion (A): In CSV file there is a blank line after every record.
Reason (R): Default value of newline is ‘\n’ in open() statement used with csv
file.
Answer:
Page 16 of 35
a. Both A and R are true and R is the correct explanation of A.
1 mark for the correct answer
19 Following code is having some errors. Rewrite the code after correcting and underlining
each correction:
x == 20
def printme():
y = x + 10
sum = 0
for i in range(x,y)
if i%3=0:
sum=sum+i+1
Elseif:
sum += 2
return(sum)
Answer:
x = 20
def printme():
y = x + 10
sum = 0
for i in range(x,y):
if i%3==0:
sum=sum+i+1
elif:
sum += 2
return(sum)
½ mark each for each correct correction
20 Write one advantage and one disadvantage of using Fiber Optic Cable.
OR
Write two differences between Circuit Switching and Packet Switching.
Answer:
Advantages (any one):
1. Fiber Optic Cable has very fast speed.
2. Fiber Optic Cables are immune to noise or attenuation.
Disadvantages (any one):
1. Fiber Optic Cables are very costly.
2. Fiber Optic Cables are difficult to maintain
½ mark for correct advantage and ½ mark for correct disadvantage
OR
1. In circuit switching a dedicated path is established between sender and receiver,
whereas, in packet switching no dedicated path is established between sender and
receiver.
2. In circuit switching there is no delay in data transmission, whereas, packet switching
experiences delay in data transmission.
3. In circuit switching there is no issue of congestion or garbled messages, whereas,
in packet switching congestion and garbled messages is a common issue.
Page 17 of 35
4. Circuit switching required long setup time, whereas, packet switching requires no
setup time.
1 mark each for each correct difference (maximum 2 marks)
21 What will be the output of the following code:
sub = “083 Comp. Sc. & 065 Info. Prac.”
n = len(sub)
s=’’
for i in range(n):
if sub[i].isupper():
s = s + sub[i].lower()
elif sub[i].islower():
s = s + sub[i]
elif sub[i].isdigit():
s = s + ‘x’
elif sub[i].isspace():
pass
else:
s = s + ‘!’
print(s)
Answer:
xxxcomp!sc!!xxxinfo!prac!
½ mark for correct display of x
½ mark for correct display of !
½ mark for correct conversion of uppercase to lowercase
½ mark for not converting lowercase too uppercase
22 Define Foreign Key. Identify foreign key from the following tables:
Table: Bank_Account
Acctno Name BCode Type
1001 Amrita A2 Savings
1002 Parthodas A3 Current
1005 Miraben A2 Current
Table: Branch
Code City
A1 Delhi
A2 Mumbai
A3 Nagpur
Answer:
A non-key attribute in a relation which is a primary key in another table can be used to
establish relationship between these tables. Such an attribute is known as foreign key in
table where it is not a primary key.
BCode attribute in table Bank_Account is a foreign key for Code attribute of table Branch.
1 mark for correct definition of Foreign Key
1 mark for correct identification of Foreign Key in example
23 a. What is the full form of SMTP and HTTP?
b. What is the use of POP3?
Page 18 of 35
Answer:
a. SMTP → Simple Mail Transfer Protocol
HTTP → HyperText Transfer Protocol
½ mark each for each correct expansion.
b. POP3 or Post Office Protocol version 3 is used to access mailbox and download e-
mail messages to the local computer.
1 mark for correct answer
24 What will be the output of the following code:
def Call4Change():
for i in range(len(lst)):
if lst[i]%2==0:
lst[i]+=1
elif lst[i]%3==0:
lst[i]+=2
elif lst[i]%5==0:
lst[i]+=4
else:
lst[i]=0
lst = [1, 2, 9, 5, 12, 6, 7, 3, 10, 8, 11, 4]
Call4Change()
print(lst)
OR
What will be the output of the following code:
def Value2New(M, N=10):
M = M + N
N = N*2
if N%10==0:
N=N/5
return(M,N)
P,Q = Value2New(100,20)
print(P,’#’,Q)
P,Q = Value2New(50)
print(P,’#’,Q)
Answer:
[0, 3, 11, 9, 13, 7, 0, 5, 11, 9, 0, 5]
½ mark for correct conversion to 0
½ mark for correct addition of 1
½ mark for correct addition of 2
½ mark for correct addition of 4
OR
120 # 8.0
60 # 4.0
1 mark each for each correct output
25 Name the SQL function that will be used in following situations:
a. To find the average salary paid to employees.
b. To find the month in which an employee is hired.
Page 19 of 35
c. To find position of a substring in customer name.
d. To find 40% of totalmarks rounded to 2 decimal places.
OR
Consider the following tables and write queries for a and b:
Table: Bank_Account
Acctno Name BCode Type
1001 Amrita A2 Savings
1002 Parthodas A3 Current
1005 Miraben A2 Current
Table: Branch
Code City
A1 Delhi
A2 Mumbai
A3 Nagpur
a. To list Acctno, Name and City of those accounts whose Account Type is
Current.
b. To display Acctno and Name of those accounts whose Code is A2.
Answer:
a. AVG()
b. MONTH()
c. INSTR()
d. ROUND()
½ mark each for each correct answer
OR
a. SELECT ACCTNO, NAME, CITY FROM BANK_ACCOUNT, BRANCH WHERE
BCODE = CODE AND TYPE = ‘Current’;
b. SELECT ACCTNO, NAME FROM BANK_ACCOUNT WHERE BCODE = ‘A2’;
1 mark each for each correct answer
26 Consider the following tables and answer the questions a and b:
Table: Garment
GCode GName Rate Qty CCode
G101 Saree 1250 100 C03
G102 Lehanga 2000 100 C02
G103 Plazzo 750 105 C02
G104 Suit 2000 250 C01
G105 Patiala 1850 105 C01
Table: Cloth
CCode CName
C01 Polyester
C02 Cotton
C03 Silk
C04 Cotton-Polyester
a. What will be output of the following command:
SELECT * FROM GARMENT NATURAL JOIN CLOTH;
b. What will be the output of following commands:
Page 20 of 35
i. SELECT DISTINCT QTY FROM GARMENT;
ii. SELECT SUM(QTY) FROM GARMENT GROUP BY CCODE HAVING
COUNT(*)>1;
iii. SELECT GNAME, CNAME, RATE FROM GARMENT G,CLOTH C WHERE
G.CCODE = C.CCODE AND QTY>100;
iv. SELECT AVG(RATE) FROM GARMENT WHERE RATE BETWEEN 1000
AND 2000;
Answer:
a. +-------+-------+---------+------+------+-----------+
| ccode | gcode | gname | rate | qty | cname |
+-------+-------+---------+------+------+-----------+
| C03 | G101 | Saree | 1250 | 100 | Silk |
| C02 | G102 | Lehanga | 2000 | 100 | Cotton |
| C02 | G103 | Plazzo | 750 | 105 | Cotton |
| C01 | G104 | Suit | 2000 | 250 | Polyester |
| C01 | G105 | Patiala | 1850 | 105 | Polyester |
+-------+-------+---------+------+------+-----------+
1 mark for complete correct output
½ mark for partially correct output
b.
i. +------+
| qty |
+------+
| 100 |
| 105 |
| 250 |
+------+
ii. +----------+
| SUM(QTY) |
+----------+
| 355 |
| 205 |
+----------+
iii. +---------+-----------+------+
| GNAME | CNAME | RATE |
+---------+-----------+------+
| Plazzo | Cotton | 750 |
| Suit | Polyester | 2000 |
| Patiala | Polyester | 1850 |
+---------+-----------+------+
iv. +-----------+
| AVG(RATE) |
+-----------+
| 1775.0000 |
+-----------+
½ mark each for each correct output
Page 21 of 35
27 Write a function countbb() in Python, which reads the contents from a text file
‘article.txt’ and displays number of occurrences of words ‘bat’ and ‘ball’ (in all possible
cases) to the screen.
Example:
If the content of file article.txt is as follows:
Bat and ball games are field games played by two opposing teams. Action starts when
the defending team throws a ball at a dedicated player of the attacking team, who
tries to hit it with a bat and run between various safe areas in the field to score runs
(points). The defending team can use the ball in various ways against the attacking
team's players to force them off the field when they are not in safe zones, and thus
prevent them from further scoring. The best known modern bat and ball games
are cricket and baseball, with common roots in the 18th-century games played
in England.
The countbb() function should display as:
Number of times bat occurs is 3
Number of times ball occurs is 5
OR
Write a function SOnly() in Python, which reads the contents from a text file ‘news.txt’
and creates another file ‘modnews.txt’. New file contains only those lines that starts
with an alphabet.
Example:
If the content of file news.txt is as follows:
This is Peter from California.
24th street is where I live.
__name__ is used in Python functions.
User defined functions is what I am presently reading.
Upon execution of function Sonly() file modnews.txt should contain:
This is Peter from California.
User defined functions is what I am presently reading.
Answer:
def countbb():
fin = open('article.txt', 'r')
data = fin.read()
fin.close()
L = data.split()
bat=ball=0
for i in L:
i = i.rstrip(".,;-'")
if i.upper() == 'BAT':
bat += 1
elif i.upper() == 'BALL':
ball += 1
print("Number of times bat occurs",bat)
print("Number of times ball occurs",ball)
½ mark for correct function header
½ mark for correct opening of file
Page 22 of 35
½ mark for correct closing of file
½ mark for correct reading of data
½ mark for correct loop and correct condition
½ mark for correct printing of output
OR
def SOnly():
fin = open('news.txt','r')
L = fin.readlines()
fin.close()
for i in L:
if i[0].isalpha()==False:
L.remove(i)
fout = open('modnews.txt','w')
fout.writelines(L)
fout.close()
½ mark for correct function header
½ mark for correct opening of files
½ mark for correct closing of files
½ mark for correct reading of data
½ mark for correct preparation of data for second file
½ mark for correct writing data in second file
28 Consider following tables and write queries for situation a and b. Find the output of c
and d:
Table: CLUB
CoachID CoachName Ag Sports Dateofapp Pay Sex
e
1 KUKREJA 35 KARATE 1996-03-27 1000 M
2 RAVINA 34 KARATE 1998-01-20 1200 F
3 KARAN 34 SQUASH 1998-02-19 2000 M
4 TARUN 33 BASKETBALL 1998-01-01 1500 M
5 ZUBIN 36 SWIMMING 1998-01-12 750 M
6 KETAKI 36 SWIMMING 1998-02-24 800 F
7 ANKITA 39 SQUASH 1998-02-20 2200 F
8 ZAREEN 37 KARATE 1998-02-22 1100 F
9 KUSH 41 SWIMMING 1998-01-13 900 M
10 SHAILYA 37 BASKETBALL 1998-02-19 1700 M
Table: COACHES
Sportsperson Sex Coach_No
AJAY M 1
SEEMA F 2
VINOD M 1
TANEJA F 3
a. To list names of all coaches with their date of appointment in descending order.
b. To display total pay given to coaches in each sport.
Page 23 of 35
c. SELECT Sportsperson, Coachname FROM Club, Coaches WHERE Coachid =
Coach_no;
d. SELECT Sex, MAX(Dateofapp), MIN(Dateofapp) FROM Club GROUP BY Sex;
Answer:
a. SELECT COACHNAME, DATEOFAPP FROM CLUB ORDER BY DATEOFAPP
DESC;
b. SELECT SUM(PAY) FROM CLUB GROUP BY SPORT;
c. +--------------+-----------+
| Sportsperson | Coachname |
+--------------+-----------+
| AJAY | KUKREJA |
| VINOD | KUKREJA |
| SEEMA | RAVINA |
| TANEJA | KARAN |
+--------------+-----------+
d. +------+----------------+----------------+
| sex | MAX(Dateorapp) | MIN(Dateorapp) |
+------+----------------+----------------+
| F | 1998-02-24 | 1998-01-20 |
| M | 1998-02-19 | 1996-03-27 |
+------+----------------+----------------+
½ mark for partially correct query (a and b)
1 mark for completely correct query (a and b)
½ mark each for each correct output (c and d)
29 Write a function SumDiv(L,x), where L is a list of integers and x is an integer;
passed as arguments to the function. The function returns the sum of elements of L
which are divisible by x or x+1.
For example,
If L Contains [10, 27, 12, 20, 22] and x is 5
Then function returns 42 (10+12+20)
Answer:
def Sumdiv(L,x):
sum = 0
for i in L:
if i%x==0 or i%(x+1)==0:
sum += i
return(sum)
½ mark for correct function header
½ mark for correct initialization of sum variable
½ mark for correct loop
½ mark for correct condition
½ mark for correct increment
½ mark for correct return statement
30 A nested list contains the records of Mobiles in the following format:
[[modelno, name, price], [modelno, name, price], [modelno, name, price],….]
Page 24 of 35
Write the following user defined functions to perform given operations on the stack
named Mobile:
a. Push operation – To push details (modelno, name, price) of those mobiles
which has price lower than 10000. Make a note that there cannot be more
than 20 elements in stack Mobile.
b. Pop operation – To pop elements from stack one by one and display them.
Also, display “Underflow” when stack becomes empty.
For example,
If the list contains
[[‘V20’, ‘Vivo 20 SE’, 18000], [‘S11’, ‘Lava S11’, 8900], [‘i88’, ‘IPro 88 SE’,
6500], [‘ip13’, ‘iPhone 13’, 125000]]
The stack should contain:
[‘i88’, ‘IPro 88 SE’, 6500]
[‘S11’, ‘Lava S11’, 8900]
The Output should be:
[‘i88’, ‘IPro 88 SE’, 6500]
[‘S11’, ‘Lava S11’, 8900]
Underflow
OR
A Dictionary Medal contains the details of schools and medals won by them in following
format {school_name:medals_won}.
Write a function Push(Medal) in Python that pushes those school names in stack
named SCHOOL which has won more than 3 medals. Maximum capacity of stack
SCHOOL is 15. Function also shows number of items pushed in stack. If number of
items exceeds 15 then it shows OVERFLOW.
For example:
If dictionary Medal contains
{‘KV1’:5, ‘KV2’:2, ‘KV3’:4, ‘KV4’:1, ‘KV5’:7}
Then stack should contain
KV5
KV3
KV1
The output should be:
Number of item pushed in stack Medal are 3
Answer:
def Push(L, mobile):
for i in L:
if i[2]<10000 and len(mobile)<20:
mobile.append(i)
elif len(mobile)>=20:
print("OVERFLOW")
break
def Pop(mobile):
while len(mobile)>0:
print(mobile.pop())
print("Underflow")
Page 25 of 35
½ mark for correct function headers
½ mark for correct loop and condition in Push
½ mark for correct push using append
½ mark for correct condition for Overflow
½ mark for correct pop statement and loop
½ mark for correct printing of overflow
OR
def Push(Medal):
x=0
for sc in Medal:
if Medal[sc]>3 and len(SCHOOL)<15:
SCHOOL.append(sc)
x+=1
elif len(SCHOOL)>=15:
print("OVERFLOW")
break
print("Number of item pushed in stack Medal are",x)
½ mark for correct function header
½ mark for correct loop
½ mark for correct condition
½ mark for correct append statement
½ mark for correct overflow condition
½ mark for correct printing of output
31 Superior Education Society is an educational Organization. It is planning to setup its
Campus at Nagpur with its head office at Mumbai. The Nagpur Campus has 4 main
buildings – ADMIN, COMMERCE, ARTS and SCIENCE.
You as a network expert have to suggest the best network related solutions for their
problems raised in a to e, keeping in mind the distances between the buildings and
other given parameters:
b.
1 mark for correct diagram
c. iii. Video Conferencing
1 mark for correct diagram
d.
i. Switch/Hub will be placed in every building to provide network connectivity
to all devices inside the building.
Page 27 of 35
ii. Repeater will not be required as there is not cable running for more than
100 meters.
½ mark each for each correct reason
e. The device/software that can be installed for data security and to protect
unauthorized access is Firewall.
1 mark for correct answer
32 a. Write the output of the Code given below:
x = 15
def add(p=2, q=5):
global x
x = p+q+p*q
print(x,end=’@’)
m = 20
n = 5
add(m,n)
add(q=10, p = -3)
b. The code given below inserts the following record in table Garment:
GCode – integer
GName – string
Rate – decimal
Qty – integer
CCode = integer
Write missing Statements (Statement 1, Statement 2 and Statement 3) to complete
the code:
import mysql.connector as mycon
cn = mycon.connect(host=’localhost’, user=’test’, password=’None’,
database=’cloth’)
cur = ______________________ #Statement 1
while True:
GCode = int(input(“Enter Garment Code = “))
GName = input(“Enter Garment Name = “)
Rate = float(input(“Enter Rate = “))
Qty = int(input(“Enter Quantity = “))
CCode = int(input(“Enter Cloth Code = “))
q = “insert into Garment Values ({}, ‘{}’, {}, {}, {}”.format(GCode,
GName, Rate, Qty, CCode)
cur._______________(q) #Staatement 2
____________________ #Statement 3
ans = input(“Do you have more records (Y/N)=”)
if ans.upper()==’N’:
break
print(“Records Successfully Saved”)
cn.close()
OR
a. Write the output of the Code given below:
def Timing(T, m=0):
Page 28 of 35
print(“Present Time is”,end=’:’)
if m>10 and m<=20:
print(“Quarter Past”,T)
elif m<=40:
print(“Half Past”,T)
elif m<=59:
print(“Quarter to”,T+1)
else:
print(“Incorrect Minutes”)
Timing(5,18)
Timing(11)
Timing(12,60)
b. The code given below reads those records from table Garment which has Qty less
than 50. Records in table Garments are stored with following attributes:
GCode – integer
GName – string
Rate – decimal
Qty – integer
CCode = integer
Write missing Statements (Statement 1, Statement 2 and Statement 3) to complete
the code:
import mysql.connector as mycon
cn = mycon.connect(host=’localhost’, user=’test’, password=’None’,
database=’cloth’)
cur = ______________________ #Statement 1
cur._________________________ #Staatement 2 (Create & Execute Query)
G = ____________________ #Statement 3 Read complete result of query
print(“Required records are:”)
for i in G:
print(i)
cn.close()
Answer:
a. 125@-23@
1 mark each for each correct output
b. Statement 1: cur = cn.cursor()
Statement 2: cur.execute(q)
Statement 3: cn.commit()
1 mark each for each correct answer
OR
a. Present Time is:Quarter Past 5
Present Time is:Half Past 11
Present Time is:Incorrect Minutes
½ mark for 1 correct output
1 mark for 2 correct outputs
2 marks for all correct outputs
b. Statement 1: cn.cursor()
Statement 2: cur.execute(“Select * from Garment where Qty<50”)
Page 29 of 35
Statement 3: cur.fetchall()
1 mark each for each correct answer
33 What is the difference between CSV file and Text File? Write a program in Python
that defines and calls the following functions:
Insert() – To accept details of clock from the user and stores it in a csv file
‘watch.csv’. Each record of clock contains following fields – ClockID, ClockName,
YearofManf, Price. Function takes details of all clocks and stores them in file in one
go.
Delete() – To accept a ClockID and removes the record with given ClockID from the
file ‘watch.csv’. If ClockID not found then it should show a relevant message. Before
removing the record it should print the record getting removed.
OR
Give one advantage of using CSV file over Binary file. Write a program in Python that
defines and calls the following functions:
saving() – To accepts details of equipments from the user in following format (ID,
Name, Make, Price) and save it in a csv file ‘parts.csv’. Function saves one record
at a time.
search() – To accept two prices and displays details of those equipments which has
price between these two values.
Answer:
Text files are plain text files which are used to store any kind of text which has no fixed
format. whereas, CSV files are also text files but they can store information in a specific
format only.
def Insert():
L=[]
while True:
ClockID = input("Enter Clock ID = ")
ClockName = input("Enter Clock Name = ")
YearofManf = int(input("Enter Year of Manufacture = "))
price = float(input("Enter Price = "))
R = [ClockID, ClockName, YearofManf, price]
L.append(R)
ans = input("Do you want to enter more records (Y/N)=")
if ans.upper()=='N':
break
import csv
fout = open('watch.csv','a',newline='')
W = csv.writer(fout)
W.writerows(L)
fout.close()
print("Records successfully saved")
def Delete():
ClockID = input("Enter Clock ID to be removed = ")
found = False
import csv
fin = open('watch.csv','r')
R = csv.reader(fin)
Page 30 of 35
L = list(R)
fin.close()
for i in L:
if i[0] == ClockID:
found=True
print("Record to be removed is:")
print(i)
L.remove(i)
break
if found==False:
print("Record not found")
else:
fout = open('watch.csv','w',newline='')
W = csv.writer(fout)
W.writerows(L)
fout.close()
print("Record Successfully Removed")
while True:
print("1. Add Clock Details")
print("2. Remove Clock Details")
print("3. Exit")
ch = int(input("Enter your choice(1-3)="))
if ch==1:
Insert()
elif ch==2:
Delete()
elif ch==3:
print("Thanks for using this program")
break
else:
print("Incorrect Choice. Please re-enter")
1 mark for correct difference between csv and text files.
Insert() function
½ mark for correct data input and making list
½ mark for correctly opening file
½ mark for correctly writing record
Delete() function
½ mark for correctly copying data in list
½ mark for correctly identifying record and removing it from the list
½ mark for correctly showing not found message
½ mark for correctly re-writing remaining records
Main
½ mark for correct main program
OR
Page 31 of 35
CSV files stores records in text format that can be read and manipulated by other
spreadsheet software like excel. However, binary files stores records in raw format and can
only be read and managed by programs only.
def saving():
L=[]
ID = input("Enter ID = ")
name = input("Enter Name = ")
Make = input("Enter Make = ")
price = int(input("Enter Price = "))
R = [ID, name, Make, price]
L.append(R)
import csv
fout = open('parts.csv','a',newline='')
W = csv.writer(fout)
W.writerows(L)
fout.close()
print("Record successfully saved")
def search():
price1 = int(input("Enter Starting Price Range = "))
price2 = int(input("Enter Ending Price Range = "))
found = False
import csv
fin = open('watch.csv','r')
R = csv.reader(fin)
L = list(R)
fin.close()
for i in L:
if int(i[3])>=price1 and int(i[3])<=price2:
found=True
print(i)
if found==False:
print("Record not found")
while True:
print("1. Add Equipment Details")
print("2. Search Equipments based on Price Range")
print("3. Exit")
ch = int(input("Enter your choice(1-3)="))
if ch==1:
saving()
elif ch==2:
search()
elif ch==3:
print("Thanks for using this program")
break
else:
Page 32 of 35
print("Incorrect Choice. Please re-enter")
1 mark for correct advantage of CSV file.
saving() function
½ mark for correct data input and making list
½ mark for correctly opening file
½ mark for correctly writing record
search() function
½ mark for correctly copying data in list
½ mark for correctly identifying record
½ mark for correctly displaying record
½ mark for correctly showing not found message
Main
½ mark for correct main program
34 Mayanti just started to work for a sports academy having several branches across India.
The sports academy appoints various trainers to train various sports. She has been
given the task to maintain the data of the trainers. She has made a table called
TRAINERS in the database which has following records:
Table: TRAINER
TrainerNo Name City HireDate Salary
101 SUNAINA MUMBAI 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHANDIGARH 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 RICHA MUMBAI 1996-01-12 95000
106 MANIPRABHA CHENNAI 2001-12-12 69000
Based on the data given above answer the following questions:
a. Can City be used as Primary key for table TRAINER? Justify your answer.
b. What is the degree and cardinality of the table TRAINER? If we add two rows
and remove three rows from table TRAINER. Also if we add another attribute
in the table, what will be the degree and cardinality of the table TRAINER will
become?
c. Write statements for:
iii. Insert a new record in table TRAINER with values, TrainerNo = 107,
Name = Swastik, HireDate = 1999-01-22, Salary = 90000.
iv. Increase the salary of those Trainer having city as DELHI by 5000.
OR
c. Write Statements for:
iii. Removes those records from table TRAINER who were hired after year
2000.
iv. Add a new column Grade with datatype as Varchar and maximum size
as 2.
Answer:
a. No. City cannot be used as Primary key for table TRAINER because it has duplicate
values in it.
½ mark for correct identification
½ mark for correct justification
Page 33 of 35
b. Before Changes: Degree = 5, Cardinality = 6
After Changes: Degree = 6, Cardinality = 5
½ mark for correct Degree and Cardinality before changes
½ mark for correct Degree and Cardinality after changes
c.
i. INSERT INTO Trainer (TrainerNo, Name, HireDate, Salary) VALUES (107,
‘Swastik’, ‘1999-01-22’, 90000);
ii. UPDATE Trainer SET Salary = Salary + 5000 WHERE City = ‘DELHI’;
OR
i. DELETE FROM Trainer WHERE Year(HireDate)>2000;
ii. ALTER TABLE Trainer ADD (Grade Varchar(2));
1 mark each for each correct query
½ mark each for partially correct query
35 Tarun Nair is working under XYZ Incorporation which deals with exporting of goods to
foreign countries. To keep track of inventory he is creating a Python program to store
the information of item number and quantity in a binary file inventory.dat. For that he
has written the following code. Go through the code given and solve problems given
below:
def write(ino,qty):
F = open(____________) #Mark 2
L= _______________ #Mark 3
L.append([ino,qty])
F.close()
F=open('inventory.dat','wb')
pickle.dump(L,F)
F.close()
def Receive(ino,qty):
F=open(“inventory.dat”,”rb”)
L=pickle.load(F)
F.close()
for i in range(len(L)):
if L[i][0] == ino:
L[i][1] += qty
F=open("inventory.dat",'wb')
pickle.dump(L,F)
________________ #Mark 4
def Sent(ino,qty):
with open(“inventory.dat”,”rb”) as F:
L=pickle.load(F)
for i in range(len(L)):
if L[i][0] == ino:
L[i][1] -= qty
with open("inventory.dat",'wb') as F:
pickle.dump(L,F)
Page 34 of 35
a. Write statement to open the file at Mark 2 to read records from the file.
b. Write statement at Mark 3 to read the content of binary file in list L.
c. Write statement at Mark 4 to close the file.
d. Why there is no need to close the file in function Sent()?
Answer:
a.
F=open(‘inventory.dat’,’rb)
b.
L=pickle.load(F)
c.
F.close()
d.
In function Sent() file is opened using with statement which implicitly closes the file
and hence there is no need to separately close the file.
1 mark each for each correct answer
**************************************************************
Page 35 of 35
KENDRIYA VIDYALAYA SANGATHAN, MUMBAI REGION
MARKING SCHEME OF SAMPLE QUESTION PAPER
CLASS-XII (SESSION 2022-23)
SUBJECT: COMPUTER SCIENCE (083)
SECTION-1
1. a) True 1
2. b) for_is 1
3. b) Tup[2] = 90 1
4. a) True 1
5. d) Error 1
6. d) Open a new fresh file, first write then read 1
7. b) split( ) 1
8. flush( ) 1
9. b) Statement-2 and statement-3 1
10. Like 1
11. c) pickle.dump(dataobject,fileobject) 1
12. List 1
13. a) router 1
14. d) 47 1
15. c) rowcount 1
16. b) list 1
17. a) Both A and R is true and R is the correct explanation of A. 1
18. d) A is false but R is true. 1
SECTION-B
19. Incorrect Correct 2
str=list("Python Program@2021') str=list("Python Program@2021”)
for Y is range(len(str)-1): for Y in range(len(str)-1):
if Y==7: if Y==7:
str[Y]=str*2 str[Y]=str*2
elif(str[Y].isupper(): elif(str[Y].isupper()):
str[Y]=str*3 str[Y]=str*3
elif(str[Y].isdigit()): elif(str[Y].isdigit()):
str[Y]='D' str[Y]='D'
print(str) print(str)
20. Hub passes the frame to every port whereas switch passes the 2
frame to a specific port, because it keeps a record of MAC address
of nodes in a network.
Hub shares its bandwidth with each and every port, so bandwidth
divided among all the nodes, which will degrade performance
whereas switch allocates full bandwidth to each of its port. So user
always access maximum amount of bandwidth.
Speed of switch is faster than hub.
OR
Star topology is better than bus topology because:
It is faster
It has less traffic
Expansion is easy i.e. easy to add new node
It has dedicated point to point connection
Central Node Control
Less chances of data collision
Easy fault detection
Signal transmission is bidirectional
21. a) [11,80] 2
b) ['violet', 'indigo', 'green', 'red']
22. Foreign Key: A non-key attribute which is primary key in another table. 2
Syntax:
ALTER TABLE table-name
ADD foreign key (field_name) references parent-table-name(attribute-
name);
23. a) 2
i) ARPANET: Advanced Research Project Agency Network
ii) URL : Uniform Resource Locator
b)
(i)
COUNT(*) Make
2 Samsung
(ii)
Max(Manufacturing_Date) Min(Price)
2022-02-16 15000
(iv)
AVG(Price)
27000
28. a) 2
(i)
Gtype count(*)
Outdoor 2
Indoor 1
(ii)
Max(DOB) Min(DOB)
2002-05-12 2000-09-21
(iii)
P.Pname P.State G.Gname
Hemali Gujarat Tennis
Gauravi Bihar Cricket
Divya Rajasthan Cricket
Ravita Punjab Badminton
(iv)
Pname Gtype DOB
Divya Outdoor 2002-05-12
Ashok Indoor 2000-12-12
n=len(L)
for i in range(n):
if L[i]%2!=0:
L[i]=L[i]+1
else:
L[i]=L[i]+2
print(L)
30. L=[ ] 3
def PUSH(D):
for i in D:
if D[i]>20000:
L.append(i)
print(L)
def POP():
if L==[]:
print("Stack is empty")
else:
L.pop()
print(L)
SECTION-D
31. (i) TECHNICAL BLOCK, because it has maximum number of computers. So, it 5
fulfills the 80:20 network rule.
(ii) Switch/Hub
(iii)
HR and Marketing Block : LAN
Head Office and Jaipur Office: WAN
(iv) Optical Fibre
(v) Star Topology
Marke
ting
HR
Techn
ical
32. a) 2
64 @ 71 +
576 @ 647 3
10 @ 12 @ 647
b)
(i) mydb.cursor()
(ii) mycursor.execute(qry)
(iii) mydb.commit()
OR
a)
i) 30-40-50-
Min value of BEGIN = 1 and LAST=2
b)
(i) mydb.cursor()
(ii) fetchall()
(iii) result
33. (i) 5
def ModifyData():
import pickle
adhr=int(input(“Enter adhaar number to modify a record: ”))
f=open("PEOPLE.dat", 'rb+')
L=pickle.load(f)
Y=[ ]
found=0
for P in L:
if P[0]==adhr:
nme=input(“Enter new name: ”)
P[0]=nme
found=1
Y.append(P)
if found==1:
f.seek(0)
pickle.dump(Y,f)
print("Record Modified Successfully")
else:
print(“Record not found”)
f.close( )
(ii)
def Show_Record():
import pickle
f=open("PEOPLE.dat", 'rb')
H=pickle.load(f)
for P in H:
if P[3]>45:
print(P)
f.close( )
OR
(i)
def WriteProduct( ):
import pickle
f=open("PRODUCT.dat", 'wb')
L=[ ]
for i in range(7):
PNo=int(input("Enter Product Number: "))
Pname=input("Enter Product Name: ")
Brand=input("Enter brand: ")
Price=float(input("Enter Price: "))
D={“pno”:PNo, “pname”:Pname, “brand”:Brand, “price”:Price}
L.append(D)
pickle.dump( L, f )
f.close( )
(ii)
def CountRecord(Brand):
import pickle
f=open("PRODUCT.dat", 'rb')
L=pickle.load(f)
count=0
for D in L:
if D[“brand”]==Brand:
count+=1
f.close( )
return count
SECTION-E
34. (i) Book_No 4
(ii) Degree= 4 and Cardinality = 6
(iii)
a) insert into books (Book_No, BookName, Price)values(777,”Poet of
India”, 225.00);
b) Select Price+Price*0.05 From Books Where BookName like “I%”;
SECTION-A
Page 1 of 12
6. What is meaning of "w+" mode: 1
a) Creating a fresh file only
b) Open an existing file, first read then write
c) Open a existing file, first write then read
d) Open a new fresh file, first write then read
9. Which of the following statement(s) would give an error after executing the 1
following code?
G=10,20,30,40 #statement-1
print(G**2) #statement-2
G[1]=35 #statement-3
R=G+(22,) #statement-4
print(R) #statement-5
12. A result set is extracted from the database using a cursor object by giving the 1
following statement:
records=mycursor.fetchall( )
What will be the data type of ‘records’ after the execution of above statement?
14. Which among the following is correct output after evaluation of the given 1
Page 2 of 12
expression:
>>> 12 - (3 % 4) // 2 + 6 ** 2
a) 46.5 b) 36 c) 12 d) 47
15. Which command is used for counting the number of rows in a database? 1
a) count b) fetchmany c) rowcount d) countrecord
16. readlines( ) method reads the data from the file and returns it into: 1
a) string b) list c) tuple d) file
18 Assertion (A): The csv files can only take comma as delimiter. 1
Reason (R): The comma is the default separator character but other popular
delimiters include the tab (\t), colon (:) and semi-colon (;)
SECTION-B
19. Rewrite the following code in python after removing all syntax error(s). 2
Underline each correction done in the code.
str=list("Python Program@2021')
for Y is range(len(str)-1):
if Y==7:
str[Y]=str*2
elif(str[Y].isupper():
str[Y]=str*3
elif(str[Y].isdigit()):
str[Y]='D'
print(str)
Page 3 of 12
OR
How is star topology better than bus topology?
b) Write Output:
colors=["violet", "indigo", "blue", "green", "yellow", "orange", "red"]
del colors[4]
colors.remove("blue")
colors.pop(3)
print(colors)
22. What is foreign key? Write syntax to make an attribute as foreign key in 2
existing table.
def ChangeString(s):
m="" #empty string
for i in range(0,len(s)):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].islower():
m=s[i].upper()+m
else:
if i%2==0:
m=m+s[i-1]
else:
m="%"+m
print(m)
ChangeString('Try2Solve@')
OR
Page 4 of 12
p=r+8
print(p)
CheckData(12)
print(p)
25. Define constraint. Write syntax to add primary key constraint in existing table. 2
OR
Write difference between Equi Join and Natural join.
SECTION-C
27. Write a function CountYouMe( ) in python which reads the content of a text file 3
“BIOGRAPHY.TXT” and counts the words ‘You’ and ‘Me’ separately. (Not case
sensitive).
Example:
If the contents in “BIOGRAPHY.TXT” are as follows:
Page 5 of 12
OR
Write a function CountDigits( ) in python which reads the content of a text file
“MyData.TXT” and counts number of digits present in the text file.
Example:
If the contents in “MyData.TXT” are as follows:
In 2023 we 22 students will appear in exam for 5 subjects
28. a) Write outputs of the SQL queries (i) to (iv) based on the relations 2
PLAYER and GAME given below:
TABLE: PLAYER
TABLE: GAME
01 Tennis 1 Outdoor
02 Cricket 11 Outdoor
03 Badminton 1 Indoor
29. Write a function EvenOdd(L) in python, to add 1 in all odd values and 2 in all 3
even values of the list L.
Example: If original elements of the list L are:
L= [35, 12, 16, 69, 26]
30. Arun has created a dictionary containing employee name and their salary as 3
key value pair of 05 employees. Create user defined functions to perform the
following operations:
i. Push the keys (name of employee) of dictionary into the stack where the
corresponding value (salary) is more than 20000.
ii. Delete the element from the stack and display the stack after deletion of
the element.
SECTION-D
31. Hill Tech Services is planning to set up its India campus at Jaipur with its Head 5
Office at Mumbai. The Jaipur campus has 3-main blocks-HR, Technical and
Marketing. You as a network expert have to suggest the best network related
solutions for their problems raised in (i) to (v).
Jaipur Campus
Marke Mumbai
ting
HR
Head
Office
Techn
ical
Page 7 of 12
Number of computers in each Block:
HR BLOCK 10
MARKETING BLOCK 45
(i) Suggest the most appropriate location of the server inside the JAIPUR
campus (out of the 3 blocks), to get the best connectivity for maximum
number of computers. Justify your answer.
(ii) Which device will you suggest to be produced by the company for
connecting all the computers within each of their offices out of the following
devices?
Switch/Hub
Modem
Bridge
(iii) Suggest network type (out of LAN, MAN, WAN) for connecting each of the
following set of their offices:
HR & Marketing Block
Head Office and Jaipur Office
c=FindOutput(q=5,r=7,p=4)
a,b=10,12
c=FindOutput(b,a,c)
print(a,"@",b,"@",c)
Page 8 of 12
b) The code given below inserts the following record in the table Employee: 3
Emp_id – integer
Ename – string
Date_of_Birth – date
Salary – float
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is computer
The table exists in a MYSQL database named Employee.
The details (Emp_id, Ename, Date_of_Birth, Salary) are to be accepted from
the user.
Write the following missing statements to complete the code:
i. Statement 1 – to form the cursor object
ii. Statement 2 – to execute the command that inserts the record in the
table Employee.
iii. Statement 3- to add the record permanently in the database
OR
import random
VALUES = [10, 20, 30, 40, 50, 60, 70, 80]
BEGIN = random.randint (1, 3)
LAST = random.randint(2, 4)
Page 9 of 12
for I in range (BEGIN, LAST+1):
print (VALUES[I], end = "-")
b) The code given below extract and display the following record from the
table Employee.
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is computer
The table exists in a MYSQL database named Employee.
The details (Emp_id, Ename, Date_of_Birth, Salary) are present in table.
Write the following missing statements to complete the code:
i. Statement 1 – to form the cursor object
ii. Statement 2 – to retrieve all records from result set object as per
query.
iii. Statement 3 - sequence object in the loop to display the records
Page 10 of 12
A binary file “PRODUCT.dat” has the following structure:
{“pno”:PNo, “pname”:Pname, “brand”:Brand, “price”:Price}
SECTION-E
Table: BOOKS
35. Alok Kumar of class 12 is writing a program to create a CSV file “project.csv” 4
which will contain student name and project name for some entries. He has
written the following code. As a programmer, help him to successfully execute
the given task.
Page 12 of 12
Class: XII Session: 2022-23
Computer Science (083)
(Theory)
Maximum Marks: 70 Time Allowed: 3
hoursGeneral 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 isgiven in Q35 against part c only.
8. All programming questions are to be answered using Python Language
only.
SECTION A
1. Python loops can also have else caluse(True/False) 1
Ans True
2. Which of the following is not a keyword? 1
a) eval b) assert c) nonlocal d) pass
Ans Eval
3 What will be the output of the following code snippet ? 1
rec={“Name”:”Python”,”Age”:”20”,”Addr”:”NJ”,”Country”:”USA”}
id1=id(rec)
del rec
rec={“Name”:”Python”,”Age”:”20”,”Addr”:”NJ”,”Country”:”USA”}
id2=id(rec)
print(id1==id2)
a) True b) False c)1 d) Exception
Ans True
4 What is the output of this code? 1
>>>int(“3”+”4”)
a) “7” b)”34” c) 34 d) 24
Ans 34
5 Select the correct output of the code 1
x=”apple,pear,peach”
y=x.split(“ , “)
for z in y:
print(z)
a) apple,pear,peach
b) pear,apple,peach
c) peach,apple,pear
d) Error
Ans apple,pear,peach
6 To read the next line of the file from a file object infi,we use 1
a) infi.read(all) b)infi.read() c)infi.readline() d) infi.readlines()
Ans infi.readline()
7 Fill in the Blank: 1
___________is not a legal constraint for a CREATE TABLE command ?
cbseexam=”BoardExamination2022-23”
Ans a) Bor
b) 6
22. Explain the use of constraints in Relational Database Management System. Give Example 2
to support your answer
23 a) Write the full form of the following 2
(i) NFS (ii) FTP
b) What is Modem ? What is its function ?
Ans i) Network File System
ii) File Transfer Protocol
b) A modem is a computer peripheral that connects a workstation to other work
stations via telephone lines and facilitates communications
Modem converts digital signals to A/F(Audio Frequency) tones which are in the
frequency range that the telephone lines can transmit and also it can convert
transmitted tones back to digital information
OR
Predict the output of the following code given below:
tuple1=(‘Jayesh’,’Ramya’,’Taruna’,’Suraj’)
list1=list(tuple1)
for Name in list1:
if Name[0]==’T’:
break
else:
print(“Finished”)
print(“Got it!”)
Ans Python
EasyEasyEasy
OR
Finished
Finished
Got it!
25 Differentiate between CHAR and VARCHAR datatypes 2
OR
Categorized the following command as TCL and DDL
ALTER,COMMIT,DROP,ROLLBACK
Ans The difference between CHAR and VARCHAR is that of fixed length and variable length.
The CHAR datatype specifies a fixed length character string. When a column is given
CHAR(n), then MySql ensures that all values stored in that column have this length i.e. n
bytes. If a value is shorter than this length n then blanks are added, byt the size of
value remains n bytes
OR
TCL-ROLLBACK,COMMIT
DDL-ALTER,DROP
SECTION C
26. a) Consider the table Hotel given below 1+2
EMPID CATEGORY SALARY
E101 MANAGER 60000
E102 EXECUTIVE 65000
E103 CLERK 40000
E104 MANAGER 62000
E105 EXECUTIVE 50000
E106 CLERK 35000
b) Write the output of the queries (i) to (iv) based on the table
TABLE-ACTIVITY
ACODE ACTIVITYNAME PARTICIPANTNUM PRIZEMONEY SCHEDULEDATE
Ans b
27. Write a method in Python to read lines from a text file DIARY.TXT and display those 3
lines which start with the alphabet ‘P’
OR
Consider a Binary file Employee.dat containing details such as
empno:ename:salary(separator ‘:’). Write a Python function to display details of those
employees who are earning between 20000 and 40000(both values inclusive)
28. a) Write the outputs of the SQL queries (i) to (iv) based on the relations DEPT and 3
WORKER
TABLE-DEPT
DCODE DEPARTMENT CITY
D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
TABLE-WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 GEORGE K 2013-09-02 1991-09-01 MALE D01
1002 RYMA SEN 2012-12-11 1990-12-15 FEMALE D03
1003 MOHITESH 2013-02-03 1987-09-04 MALE D05
1007 ANIL JHA 2014-01-17 1984-10-19 MALE D04
1004 MANILA SAHAI 2012-12-09 1986-11-14 FEMALE D01
1005 R SAHAY 2013-11-18 1987-03-31 MALE D02
1006 JAYA PRIYA 2014-06-09 1985-06-23 FEMALE D05
OR
Write a function in Python, Push(Client) where , Client is a dictionary containing the
details of clients– {Cname:age}. The function should push the names of those client in
the stack who have age greater than 50. Also display the count of elements pushed into
the stack. For example: If the dictionary contains the following data:
Cname={"Robert":55,"Jhon":35,"Smith":75,"Reyan":25} The stack should contain Robert
Smith The output should be: The count of elements in the stack is 2
Ans def MakePush(Package):
a=int(input(“Enter Package Title”))
Package.append(a)
def MakePop(package):
if(Package==[]):
print(“Stack empty”)
else:
print(“Deleted element:”,Package.pop())
OR
SECTION D
31. Hi Standard Tech Training Ltd. is a Mumbai based organization which is 5
expanding its office set-up to Chennai. At Chennai office compound, they are
planning to have 3 different blocks for Admin, Training and Accounts related
activities. Each block has a number of computers, which are required to be
connected in a network for communication, data and resource sharing.
As a network consultant, you have to suggest the best network related
solutions for them for issues/problems raised by them in (i) to (v), as per the
distances between various blocks/locations and other given Parameters
Number of Computers-
Training Block=150
Admin Block=50
i) Suggest the most appropriate place for the server in the Chennai Office
to get the best effective connectivity. Justify your answer
ii) Suggest the best wired medium for connection of computers in the
Chennai office
iv) Suggest a device /software and its placement that would provide data
security for the entire network of the Chennai office
v) Suggest a device and the protocol that shall be needed to provide
wireless Internet access to all smartphones /laptop users in the
Chennai office
(b) The code given below inserts the following record in the table Books:
Title – String
AuthorName – string
ISBN_No – String
Price – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named Library.
• The details (Title, AuthorName, ISBN_No and Price) 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 mysql
def Library_data():
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="Library")
mycursor=_________________ #Statement 1
Title=input("Enter Book Title :: ")
AuthorName=input("Enter Book Author Name :: ")
ISBN_No=input("Enter Book ISBN Number:: ")
Price=int(input("Enter Price of Book :: "))
querry="insert into Books values({},'{}',{},{})".format(Title,AuthorName ,
ISBN_No,Price)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")
OR
y= 10 a= 2
a+y= 12
12
y= 5 a= 2
b)
Statement 1: con1.cursor()
Statement 2: mycursor.execute(querry)
Statement 3: con1.commit()
OR
a) SCHOOLbbbbCOM
b)
Statement 1: con1.cursor()
Statement 2: mycursor.execute("select * from books where Price>=200")
Statement 3: mycursor.fetchall()
33. 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:
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:
Ans Difference between binary file and csv file: (Any one difference may be given)
Binary file:
• Extension is .dat
CSV file:
• Extension is .csv
• Human readable
Program:
import csv
def add():
fout=open("furdata.csv","a",newline='\n')
wr=csv.writer(fout)
FD=[fid,fname,fprice]
wr.writerow(FD)
fout.close()
def search():
fin=open("furdata.csv","r",newline='\n')
data=csv.reader(fin)
found=False
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")
fin.close()
add()
print("Now displaying")
search()
SECTION E
TABLE-BOOKS
TABLE-ISSUED
Book_id Quantity_Issued
T0001 4
C0001 5
F0001 2
i) To Show Book name,Author name and Price of books of First Publ Publishers
ii) To display the names and price from books in ascending order of their price,
iii) Write the statement to
a) To insert a new row in the table issued having the following data:’F0003”,1
b) To increase the price of all books of EPB Publishers by 50
OR
OR
35. Aaruni Shah is learning to work with Binary files in Python using a process known 5
as pickling/de-pickling. 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
import___________ # Fill_Line1
sqlist=list()
for k in range(10):
sqlist.append(k*k)
fout=________________ #Fill_Line 2
_______________________ #Fill_Line 3
fout.close()
fin=_____________________ #Fill_Line 4
________________________ #Fill_Line 5
fin.close()
(a) Complete Fill_Line1 so that the required library becomes available to the
program
(b) Complete Fill_Line 2 so the above mentioned binary file is opened for
writing in the file object fout
(c) Complete Fill_Line 3 so that list created in nthe code , namely Sqlist, is
written in the open file.
(d) Complete Fill_Line 4 which will open the same binary file for reading in the
file object fin.
(e) Complete Fill_Line 5 so that the contents of the open file in the file handle
fin are read in a list namely mylist.
Ans a) import pickle
b) fout=open(“Mydata.dat”,’wb’)
c) pickle.dump(sqlist,fout)
d) fin=open(‘Mydata.dat’,’rb’)
e) mylist=pickle.load(fin)
;Class: XII Session: 2022-23
Computer Science (083)
(Theory)
Maximum Marks: 70 Time Allowed: 3
hoursGeneral 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 isgiven in Q35 against part c only.
8. All programming questions are to be answered using Python Language
only.
SECTION A
1. Python loops can also have else caluse(True/False) 1
2. Which of the following is not a keyword? 1
a) eval b) assert c) nonlocal d) pass
3 What will be the output of the following code snippet ? 1
rec={“Name”:”Python”,”Age”:”20”,”Addr”:”NJ”,”Country”:”USA”}
id1=id(rec)
del rec
rec={“Name”:”Python”,”Age”:”20”,”Addr”:”NJ”,”Country”:”USA”}
id2=id(rec)
print(id1==id2)
a) True b) False c)1 d) Exception
20. Write two points of difference between Twisted Pair Cables and Coaxial Cables 2
OR
Write two points of difference between SMTP and POP3
21. a) Given is a Python string declaration: 2
cbseexam=”BoardExamination2022-23”
22. Explain the use of constraints in Relational Database Management System. Give Example 2
to support your answer
23 a) Write the full form of the following 2
(i) NFS (ii) FTP
b) What is Modem ? What is its function ?
24 Predict the output of the following code given below: 2
def func(message,num=1):
print(message*num)
func(‘Python’)
func(‘Easy’,3)
OR
Predict the output of the following code given below:
tuple1=(‘Jayesh’,’Ramya’,’Taruna’,’Suraj’)
list1=list(tuple1)
for Name in list1:
if Name[0]==’T’:
break
else:
print(“Finished”)
print(“Got it!”)
25 Differentiate between CHAR and VARCHAR datatypes 2
OR
Categorized the following command as TCL and DDL
ALTER,COMMIT,DROP,ROLLBACK
SECTION C
26. a) Consider the table Hotel given below 1+2
EMPID CATEGORY SALARY
E101 MANAGER 60000
E102 EXECUTIVE 65000
E103 CLERK 40000
E104 MANAGER 62000
E105 EXECUTIVE 50000
E106 CLERK 35000
b) Write the output of the queries (i) to (iv) based on the table
TABLE-ACTIVITY
ACODE ACTIVITYNAME PARTICIPANTS NUM PRIZEMONEY SCHEDULEDATE
OR
Write a function in Python, Push(Client) where , Client is a dictionary containing the
details of clients– {Cname:age}. The function should push the names of those client in
the stack who have age greater than 50. Also display the count of elements pushed into
the stack. For example: If the dictionary contains the following data:
Cname={"Robert":55,"Jhon":35,"Smith":75,"Reyan":25} The stack should contain Robert
Smith The output should be: The count of elements in the stack is 2
SECTION D
31. Hi Standard Tech Training Ltd. is a Mumbai based organization which is 5
expanding its office set-up to Chennai. At Chennai office compound, they are
planning to have 3 different blocks for Admin, Training and Accounts related
activities. Each block has a number of computers, which are required to be
connected in a network for communication, data and resource sharing.
As a network consultant, you have to suggest the best network related
solutions for them for issues/problems raised by them in (i) to (v), as per the
distances between various blocks/locations and other given Parameters
Shortest distances between various blocks/locations:
Admin Block to Accounts Block 300 Metres
Number of Computers-
Training Block=150
Admin Block=50
i) Suggest the most appropriate place for the server in the Chennai Office
to get the best effective connectivity. Justify your answer
ii) Suggest the best wired medium for connection of computers in the
Chennai office
iv) Suggest a device /software and its placement that would provide data
security for the entire network of the Chennai office
v) Suggest a device and the protocol that shall be needed to provide
wireless Internet access to all smartphones /laptop users in the
Chennai office
32 a). Write the output of the code given below: 2+3
a=10
y=5
def myfunc():
global a
y=a
a=2
print(“y=”,y, ”a=”,a)
print(“a+y=”,a+y)
return a+y
print(“y=”,y,”a=”,a)
print(myfunc())
print(“y=”,y, “a=”,a)
(b) The code given below inserts the following record in the table Books:
Title – String
AuthorName – string
ISBN_No – String
Price – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named Library.
• The details (Title, AuthorName, ISBN_No and Price) 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 mysql
def Library_data():
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="Library")
mycursor=_________________ #Statement 1
Title=input("Enter Book Title :: ")
AuthorName=input("Enter Book Author Name :: ")
ISBN_No=input("Enter Book ISBN Number:: ")
Price=int(input("Enter Price of Book :: "))
querry="insert into Books values({},'{}',{},{})".format(Title,AuthorName ,
ISBN_No,Price)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")
OR
(i) 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.
(ii) (ii) COUNTR() – To count the number of records present in the CSV file
named ‘record.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:
TABLE-BOOKS
TABLE-ISSUED
Book_id Quantity_Issued
T0001 4
C0001 5
F0001 2
i) To Show Book name,Author name and Price of books of First Publ Publishers
ii) To display the names and price from books in ascending order of their price,
iii) Write the statement to
a) To insert a new row in the table issued having the following data:’F0003”,1
b) To increase the price of all books of EPB Publishers by 50
OR
35. Aaruni Shah is learning to work with Binary files in Python using a process known 5
as pickling/de-pickling. 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
import___________ # Fill_Line1
sqlist=list()
for k in range(10):
sqlist.append(k*k)
fout=________________ #Fill_Line 2
_______________________ #Fill_Line 3
fout.close()
fin=_____________________ #Fill_Line 4
________________________ #Fill_Line 5
fin.close()
(a) Complete Fill_Line1 so that the required library becomes available to the
program
(b) Complete Fill_Line 2 so the above mentioned binary file is opened for writing
in the file object fout
(c) Complete Fill_Line 3 so that list created in nthe code , namely Sqlist, is
written in the open file.
(d) Complete Fill_Line 4 which will open the same binary file for reading in the
file object fin.
(e) Complete Fill_Line 5 so that the contents of the open file in the file handle
fin are read in a list namely mylist.
KENDRIYA VIDYALAYA SANGATHAN – MUMBAI REGION
Sample Question Paper (2022-2023)
Class: XII Time: 3 Hours
Subject: Computer Science (083) Max. Marks: 70
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 1 mark each.
4. Section B has 7 very short answer type questions carrying 2 marks each.
5. Section C has 5 short answer type questions carrying 3 marks each.
6. Section D has 3 long answer type questions carrying 5 marks each.
7. Section E has 2 long answer type questions carrying 4 marks each.
8. Internal choices are given in few questions.
9. All programming questions are to be answered using PYTHON language only.
SECTION – A
1 Identify the name(s) from the following that cannot be used as identifiers in 1
Python:
Name, for, a_123, True
Answer :
for, True
½ mark for each correct answer
2 Name the datatype for the following: 1
a. L=25,
b. T={25:”money”, “money”:25}
Answer :
a. Tuple
b. Dictionary
½ mark for each correct answer
3 Which is the correct way to remove an item from dictionary i.e. Tuesday 1
WEEKD={‘mon’:Monday’, ‘tue’:’Tuesday’, ‘wed’,’Wednesday’}
a. Del WEEKD(‘Tuesday’)
b. Del WEEKD[‘Tue’]
c. del WEEKD[‘tue’]
d. both b and c
Answer:
c. del WEEKD[‘tue’]
1 mark for correct answer
4 Which of following expression(s) is an example of type casting 1
(a) 4.0 +float(6) (b)5.3 +6.3 (c) 5.0 +3 (d) int(3.1)
+7
Answer:
(a) 4.0 + float(6) , (d) int(3.1)+7 both are example of type casting
½ mark for each correct answer
Page 1 of 18
5 What will be the output of the following: 1
S= “python is very funny language”
print(S.split(“n”))
Answer:
[‘pytho’, ‘is very fu’, ‘y la’, ‘ ‘, ‘guage’]
½ mark for partial correct , 1 mark for fully correct
6 Which function is used to read a single line from a file ? 1
(a) Readline( ) (b) readline( ) (c) Readlines( ) (d)
readfullline( )
Answer:
(b) readline( )
1 mark for correct answer
7 Fill in the blank: 1
_____________Command used to remove/drop a column(attribute) from the
table(relation).
a. Update b. Drop c. Alter d.Remove
Answer:
c. Alter
1 mark for correct Answer
8 Rohan created a table Company and inserted two records now he wants to 1
change the value in city column and wants to put value of city column is ‘
DELHI’ for both the records, write command to update the record in a table.
Answer:
UPDATE COMPANY SET CITY=’DELHI’;
1 mark for correct answer
9 What will be the output of the following code: 1
Color = ‘Color helps to give shadow to the picture’
newcolor = Color.replace(‘o’,’#’)
print(newcolor)
Answer:
C#l#r helps t# give shad#w t# the picture
½ mark for partial change of ‘o’ , 1 mark for complete correct output
10 Fill in the blank: 1
`__________ command is used to delete all the record, structure of a table
must exist in database after deleting all the record of a table
(a) DROP (b) DELETE (c) ALTER (d) None of
these
Answer: DELETE
1 mark for correct answer
11 Which of the following mode is used for both writing and reading in binary in 1
file
a. wr+ b. wb+ c. w+ d. wr
Answer:
Page 2 of 18
b. wb+
1 mark for correct answer
12 In database School there are two table Student (containing 5 records) and Fee 1
(containing 3 records). Sohan displayed data from both the tables using select
command, then total 15 rows (records) displayed , which type of joining is
implemented when, Sohan displayed records
a. Equi Join b. Cross Join c. Natural Join d. none of these
Answer :
b. Cross Join
1 mark for correct answer
13 _____________ protocol is used to transmit the data between devices and 1
containing address of node also
a. SMTP b. PPP c. UDP d. TCP/IP
Answer:
d. TCP/IP (1 mark for correct answer)
15 Aman store 5 five in table ‘student’ and for attribute fee Rs. 1
1500,2500,3000,1000,NULL stored respectively. Aman executed the below
command in SQL :
Select average(fee) from student;
After executing the above command for NULL fee record Rs. 4500 updated in
the table student .
on the basis of above select command what will be the average of fee will come
as output:
a. 1600 b. 2000 c. 2500 d. None of the above
Answer:
b. 2000
1 mark for correct answer
SECTION – B
19 Rewrite the following code in Python after removing all syntax error(s). Underline 2
each correction done in the code:
Value=30
Def Display(Value): #
Function Define
for VAL in range(0,Value)
if(val%4==0):
print(VAL*4)
elif(VAL%5==0):
Print(VAL+3)
Else:
print(VAL+10)
Display(30) #
Function call
Answer:
Value=30
def Display(Value): #
Function Define
for VAL in range(0,Value):
if(VAL%4==0):
print(VAL*4)
elif(VAL%5==0):
print(VAL+3)
else:
print(VAL+10)
Display(30) #
Function call
Page 4 of 18
½ mark for each correction , 2 marks all correction and proper syntax
1 mark for difference and 1 mark for writing correct web browsers name
Answer:
fUNnpYTHONn3.7.
2 marks for correct output
Page 6 of 18
OR
Predict the output of the python code given below:
T=25,26,27,28,29
L=list(T)
NL=[ ]
for I in L:
if(i%2==0):
NL.append(i)
else:
NL.append(i-1)
NP=tuple(NL)
print(NP)
Answer :
(25,26,26,28,28)
2 marks for correct output
25 Mohan facing problem to apply SQL functions help him as per below circumstances
and suggest correct function with column name if any as per given statement:-
a. Want to count total number of record of a table(relation) ½
b. Want to find the average of fees received in the vidyalaya ½
c. Want to count for a column city how many city entered in the
column(attribute) except null values ½
d. Want to find the maximum fee paid by a student in the Vidyalaya ½
Answer:
a. Count(*) b. avg(fee) c. Count(city) d. Max(fee)
½ mark for each correct answer
OR
SECTION – C
26 Consider the following tables and answer the questions a and b:
Table: School
SID SName Fee Class CCode
S101 JATIN 2000 11 C1101
Page 7 of 18
S102 PARTH 1500 11 C1102
S103 SNEHA 1800 12 C1202
S104 PRADEEP 2750 11 C1101
S105 ABHINAV 2400 12 C1201
Table: TEACHER
CCode TName
C1101 PRAMOD
C1102 SMARAT
a. What will be output of the following command: 1
SELECT * FROM SCHOOL NATURAL JOIN TEACHER;
b. What will be the output of following commands:
i. SELECT DISTINCT CLASS FROM SCHOOL; ½
ii. SELECT CCODE, SUM(FEE) FROM SCHOOL GROUP BY CCODE ½
HAVING COUNT(*)>1;
iii. SELECT SNAME, TNAME, FROM SCHOOL S, TEACHER T ½
WHERE S.CCODE = T.CCODE AND FEE>2000;
iv. SELECT AVG(FEE) AS AVGFEE FROM SCHOOL WHERE FEE ½
BETWEEN 1500 AND 1800;
Answer:
a. SELECT * FROM SCHOOL NATURAL JOIN TEACHER;
SID SName Fee Class CCode TNAME
S101 JATIN 2000 11 C1101 PRAMOD
S102 PARTH 1500 11 C1102 SMARAT
S104 PRADEEP 2750 11 C1101 PRAMOD
b(i).
SID
S101
S102
b(ii)
CCODE FEE
C1101 4750
C1102 1500
C1202 1800
C1201 2400
b(iii)
SNAME TNAME
PRADEEP PRAMOD
b(iv)
AVGFEE
1650
3 marks for correct output of sub parts of a (1 mark) , b(I to iv) ( ½ mark each)
Page 8 of 18
27 Write a function displayMyMe() in python that counts the number of “Me” or 3
“My” words present in the 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 known to the world.
The output of the function should be
Count of My/Me in file : 4
Answer:
def displayMyMe():
num=0
f=open(“STORY.txt,’r’)
N=f.read()
M=N.split()
for X in M:
if (X==”Me” or “My”):
num=num+1
f.close()
print(“Count of My/Me in file : “, num)
OR
Write a function vowelcount() in Python , which should read each character of
a text file POEM.txt, should count and display the occurrence of vowels (including
both cases)
Example
If the file content is as follows :
You are good student of class
Total Vowels : 10
Answer:
def vowelcount():
f=open(“POEM.txt,’r’) # r mode if not mention then it default take read mode
vowel=[‘a’,’e’,’i’,’o’,’u’,’A’,’E’,’I’,’O’,’U’]
count=0
data=f.read()
for i in data:
if i in vowel:
count=count+1
print(“ Total Vowels : “,count)
f.close()
Page 9 of 18
½ mark for defining correct function with colon(:)
1 mark for opening file correctly, ½ mark for read() if data read correctly
½ marks for if condition to check vowel, ½ mark for print statement
28 Consider the relations(tables) Games and Player and write the output of the
query for a (i) to (iv) ( ½ mark each= 2 marks) ,(b) write the command
as per statement
Table: GAMES
GCode GName Number Gametype Prize Sdate
G101 Carom 2 Indoor 15000 2022-07-02
G102 Badminton 2 Outdoor 12000 2021-09-15
G103 Table Tennis 4 Indoor 8000 2022-07-25
G104 Chess 2 Indoor 7000 2020-10-01
G105 Lawn Tennis 4 Outdoor 20000 2022-11-01
Table: PLAYER
PCOD PNAME GCode
E
P1 PRAMOD G101
P2 SMARAT G102
P3 DIPAK G103
½
P4 NILESH G105
½
(a) Write the output of all statements (Queries)
(i) SELECT Gametype, avg(Prize) from GAMES group by Gametype;
(ii) SELECT max(Sdate), min (Sdate) from GAMES;
½
(iii) SELECT Gname, Gametype, G.GCode, , Pname FROM Games G,
Player P WHERE G.GCode=P.GCode and Prize>10000;
½
(iv) SELECT Gname, Pname from Games G, Player P where
Number>=4 and G.GCode=P.GCode;
1
(b) Write a Query to insert a record in to table GAMES :
GCode GName Number Gametype Prize Sdate
G106 Chess 2 Indoor 12000 2022-10-11
Page 10 of 18
Carom Indoor G101 PRAMOD
Badminton Outdoor G102 SMARAT
Lawn Tennis Outdoor G105 NILESH
(iv)
Gname Pname
Table Tennis DIPAK
Lawn Tennis NILESH
b.
INSERT into Games values(‘G106’,’Chess’, 2, ‘Indoor’, 12000, ‘2022-10-11’);
29 Write a function LShift(Arr,n) in Python, which accepts a list Arr of numbers and 3
n is a numeric value by which all elements of the list are shifted to left.
Sample Input date of the list
Arr=[10,20,30,40,12,11] , n=2
Output
Arr=[30,40,12,11,10,20]
Answer :
def LShift(Arr,n):
L=len(Arr)
for x in range(0,n):
y=Arr[0]
for i in range(0,L-1):
Arr[i]=Arr[i+1]
Arr[L-1]=y
print(Arr)
ANSWER:
student=[]
def Push(student):
stud_name=input(“ enter the name of student”)
S=[stud_name]
Student.append(S)
print(“student record added into the stack”)
Page 11 of 18
or any correct program
½ mark of declaration of list , ½ mark for defining correct function,
1 mark for inputting name , 1 mark for append record in stack list
OR
Write a function in Python Pop(student) , where student is a stack
implemented by a list of student name . The function returns the value deleted
from the stack.
student list containing student record
ANSWER:
def Pop(student):
if (student==[]):
print(“stack is empty”)
else:
n=student.pop()
print(n, “student record deleted from the stack”)
SECTION D
31 Three student of KV started a business company Alumni University and setting up
its academic block in Mumbai and is planning to set up of a network. The
University has 3 academic block (BUSINESS, TECHNOLOGY, LAW) and one
Human Resources Centre as shown in the diagram below:
ANSWER:
(i) Server will be installed in HR Center because of having maximum number
of computer in the area
(ii) Make a layout That connect all blocks with HR center (or any proper best
layout)
(iii) Switch will be installed in all blocks/center to connect all the computers in
a network
(iv) Repeater may be placed when the distance between two blocks is more
than 70-80 meter
(v) WAN, because the given distance is more than the range of LAN and WAN
a = 20
b = 5
product(a,b)
product(q=3, p = 2)
Answer
200#12#
1 mark for each correct output
b. The code given below used to insert the record in table Games of database
STATEGAME: 3
Page 13 of 18
GCode – integer
GName – string
Number – integer
Prize – integer
Write missing Statements (Statement 1, Statement 2 and Statement 3) to complete the
code for executing the program in python using myconnector:
Answer
Statement 1: cur = connection.cursor()
Statement 2: cur.execute(row)
Statement 3: connection.commit()
1 mark each for each correct answer
33 What is the use of CSV file in Python Programming? how its helps to store 5
data in it.? Write a program in Python that defines and call the following user
define functions:-
add() – To accept and add data of an student in to a CSV file “school.csv”.
Each record consists of a list with field elements as sid, sname and class to add
student id, student name and class respectively.
Count() – To count the number of records present in the CSV file named
‘school.csv’
ANSWER
CSV file in python programming helps to store data like a text file in a format COMMA
SEPERATED VALUE. The extension of CSV file is .csv , it’s a Human Redable format.
This file can be open in Excel and Notepad also
Page 14 of 18
import csv
def add():
fout=open(“school.csv”,’a’, “newline=’\n’)
wrow=csv.writer(fout)
sid=int(input( “enter the student id”))
sname=input(“enter the student name”)
class=int(input(“enter class in number in which student studying”))
row=[sid,sname,class]
wrow.writerow(row)
fout.close()
def Count():
fin=open((“school.csv”,’a’, “newline=’\n’)
data=csv.reader(fin)
record=list(data)
print(len(record))
fin.close()
add()
Count()
1 mark for explaining the use of CSV file, ½ mark for importing csv module
1½ mark for making add() correct storing the data and 1 ½ counting the total number
of records from a CSV file
½ mark function calling
SECTION E
34 Rohan just started to work for a sports academy having several branches across
India. The sports academy appoints various trainers to train various sports. She
has been given the task to maintain the data of the trainers. She has made a
table called TRAINERS in the database which has following records:
Table: TRAINER
TNo TName City HireDate Salary
101 SUNAINA MUMBAI 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHANDIGARH 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
Page 15 of 18
105 RICHA MUMBAI 1996-01-12 95000
106 MANIPRABHA CHENNAI 2001-12-12 69000
Based on the data given above answer the following questions:
a. Which column will be the primary key in this table justify your answer?
b. What is the degree and cardinality of the table TRAINER? If we add
three rows and after that remove two rows from table TRAINER. Also if 1
we add two another attribute in the table, what will be the degree and 1
cardinality of the table TRAINER will become?
c. Write statements for:
i. Insert a new record in table TRAINER with values, TN = 107,
TName = ‘Pramod’, City=’ DELHI’ HireDate = ‘1999-01-22’,
Salary = 90000. 1
ii. Increase the salary of those Trainer having city as DELHI by 5000.
OR (option for part C only) 1
c. Write Statements for:
i. Removes those records from table TRAINER who were hired after
year 2000. 1
ii. Add a new column Game with datatype as Varchar and maximum
size as 20. 1
Answer:
a. Tno column in the table (relation) can be declare as Primary key because of
having unique value.
1 mark for correct justification or any correct justification
b. Before Changes: Degree = 5, Cardinality = 6
After Changes: Degree = 7, Cardinality = 7
½ mark for correct Degree and Cardinality before changes
½ mark for correct Degree and Cardinality after changes
c.
i. INSERT INTO Trainer (TNo, TName, City, HireDate, Salary) VALUES
(107, ‘Pramod’,’Delhi’, ‘1999-01-22’, 90000);
ii. UPDATE Trainer SET Salary = Salary + 5000 WHERE City = ‘DELHI’;
OR (option for part (c) only
i. DELETE FROM Trainer WHERE Year(HireDate)>2000;
ii. ALTER TABLE Trainer ADD (Game Varchar(20));
1 mark each for each correct query
½ mark each for partially correct query
35 SMARAT is working under KVS, which deals with student record and want to
store data in to file with the information of STUDENT id and student name in
a binary student.dat. student will go aboard , if id of the student will match .
For that he has written the following code. Go through the code given and solve
problems given below:
def write(id,name):
Page 16 of 18
F = open(____________) #Statement 1
L= _______________ # Statement 2
L.append([id,name])
F.close()
F=open('inventory.dat','wb')
pickle.dump(L,F)
F.close()
def Receive(id,name):
F=open(“inventory.dat”,”rb”)
L=pickle.load(F)
F.close()
for i in range(len(L)):
if L[i][0] == id:
L[i][1] += qty
F=open("student.dat",'wb')
pickle.dump(L,F)
________________ #Statement 3
def Sent(id,name):
with open(“student.dat”,”rb”) as F:
L=pickle.load(F)
for i in range(len(L)):
if L[i][0] == id:
L[i][1] -= name
with open("student.dat",'wb') as F:
pickle.dump(L,F)
a. Write python code to open the file at Statement 1 to read records from the file. 1
b. Write python code at Statement 2 to read the content of binary file in list L. 1
c. Write python code at Statement 3 to close the file. 1
d. Why binary file is more accurate to store the data for future use? 1
Answer:
a. F=open(‘student.dat’,’rb)
b. L=pickle.load(F)
c. F.close()
d. Binary file in python store the data in machine understandable format, user can not read the
data from a file. It is a portable file to transfer the data from one computer to another like a
Page 17 of 18
python program is also portable. In this file security of data is easily maintainable because it
is not understandable for individual user.
Page 18 of 18
Kendriya Vidyalaya Sangathan
Mumbai Region
Class XII ( Session 2022-23) Subject :- Computer Science (083)
Sample Question Paper (Theory)
Marking Scheme
Time :- 3:00 hr M.M. :- 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(d) only.
8. All programming questions are to be answered using Python Language only.
Section :- ( A)
Ans 1:- False 1
Ans 2:- (c) 1
Ans 3:- (a) 1
Ans 4:- (a) 1
Ans 5:- (b) 1
Ans 6 :- Immutable 1
Ans 7:- (b) 1
Ans 8:- (d) 1
Ans 9 :- False ½ +½
True
Ans10 :- (d) 1
Ans 11:- (a) 1
Ans 12:- (c) 1
Ans13 :- (c) 1
Ans 14:- (a) 1
Ans 15:- (c) 1
Ans 16 :- (c) 1
Ans 17: (a) 1
Ans 18:- (d) 1
SECTION ( B )
Ans 19:- def sum(c) : 2
s=0 (½
for i in range (1, c+1): +½+½
s=s+i +½)
return s
print(sum(5))
OR
Page 1 of 6
A hub shares and distributes bandwidth among all connected computers whereas a switch does
not share bandwidth , rather each computer gets full bandwidth.
Ans 22:- Primary key cannot have NULL value , the unique constraints can have NULL values . There is
only one primary key in a table , but there can be multiple unique constraints . The primary key
creates the cluster index automatically but the Unique key does not.
(b) Microwave signals are used to transmit data without the use of cables . The microwave 1
signals are similar to radio and television signals and are used for long distance communication.
(1 mark for find wrong statement and 1 mark for correct code )
SECTION ( C)
Ans 26 :- (a) (i) 1 (ii) 1 (iii) 80000 (iv) 23800 2
(½ mark for each)
(b) An Equijoin is a special type of join where two tables are joined on the basis of common
column having equal values i.e it is based upon we use only an equality operator . The EQUI 1
join shows the common columns from all the participating tables .
(½ mark for correct function header , 1 mark for correct outer loop ,1 mark for correct inner
loop statement , ½ mark for print statement)
Page 2 of 6
Ans 28:- def count_A_M( ) 3
f= open (“story.txt”, “r”)
A,M =0,0
r=f.read ( )
for x in r :
if x[0] == “A” or x[0] == ‘a’ :
A=A+1
elif x[0]== ‘M’ or x[0] == ‘m’:
M=M+1
f.close ( )
print (“A or a : ”, A)
print (“M or m : ”, M)
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)
Page 3 of 6
OR
Book [ ]
def Addnew (s):
Name = input (“Enter Book Name ”)
Book.append (Name)
SECTION ( D)
Ans 31 :- (i) 4=
Raj Fazz
Building Building
Harsh Jazz
Building Building
1
(ii) The most suitable place /block to house the server of this organization would be Raj Building
, as this block contains the maximum number of computer , thus decreasing the cabling cost for
most of the computers as well as increasing the efficiency of the maximum computers in the ½ +½
network.
(½ mark for naming the server block and ½ mark for correct reason.)
(iv) The type of network that shall be formed to link the sale counters situated in various parts of
the same city would be a MAN, because MAN (Metropolitan Area Networks) are the 1
networks that link computer facilities within a city.
Page 4 of 6
(1 mark for correct option ans ½ marks for each correct lower and upper value answer )
(b) Fetchall ( ) fetches all the rows of a query result (the resultset). An empty list is returned if
ther is no record matching as per the given SQL query.
3
Fetchone ( ) method retursn one row or a single reocrd at a time from the resultset. It will return
None if no more rows /records are available .
For example , if the SQL query returned two records in the resultset such as :
101 Rushil 97.5
106 Anya 98.0
then fetchall ( ) will get all the recorsd (i.e both records shown ) in one go. And fetchone ( ) will
first get the fist record and after using fetchone( ) again , it will get the second record.
( 1 mark for each correct answer and ½ mark for each example )
OR
(a) Global names : invaders, pos , level ,res
Local names : max_level 1
1
( 1 mark for each correct answer )
(b)
(i) A database cusror is a special control structure that facilities the row by row processing of the
records of the resultset .
The resultset refers to a logical set of records that are fetched from the database by
executing an SQL query and made avaliable to the application program.
OR
(d) Des or Describe Store ( 1 mark for correct answer )
Ans :- 35 import pickle
sturno = int (input (“Enter roll number:=” ))
stuname= input (“Enter name :”)
stumarks= float (input (“Enter marks : ”))
Stu1= {“RollNo. ” : sturno , “Name ” : stuname, “Marks ” : stumarks }
Page 5 of 6
(a) with open (“Stu.dat”, “wb” ) as fh : 1
(b) pickle. Dump (Stu1, fh) 1
(c) with open (“Stu.dat ” , “rb”) as fin : 1
**************************************************************************
Page 6 of 6
Kendriya Vidyalaya Sangathan
Mumbai Region
Class XII ( Session 2022-23) Subject :- Computer Science (083)
Sample Question Paper (Theory)
Time :- 3:00 hr M.M. :- 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(d) only.
8. All programming questions are to be answered using Python Language only.
Section :- A
1. State True or False 1
“A list of character is similar to a string type ”
2. Which of the following is not a tuple function ? 1
(a) min ( ) (b) max( ) (c) update( ) (d) count( )
3. Write the output of the following code :- 1
a= {‘a’: “Apple”, ‘b’: “Banana” , ‘c’: “Cat”}
a[‘a’]= “Anar”
print (a)
def functions1(a) :
a= a+ ‘1’
a=a*2
function1 (“hello”)
Page 1 of 8
7. What is the difference between r+ and w+ modes ? 1
(a) No difference
(b) In r+ mode , the pointer is initially placed at the beginning of the file and for w+ the
pointer is placed at the end
(c) In w+ mode , the pointer is initially placed at the beginning of the file and for r+ the
pointer is placed at the end
(d) Depends on the operating system.
8. What is the value of the following expression ? 1
21//4+6/3
10. What kind of transmission medium is most appropriate to carry data in a computer network that 1
is exposed to electrical interferences?
(a) Unshielded twisted pair (c) Microwave
(b) Coaxial cable (d) Optical Fiber
11. Which of the following keywords will you use in the following query to display all the values of 1
the column dept_name ?
12. Which operator tests column for the absence of data (i.e. NULL value) ? 1
(a) EXISTS operator (b) NOT operator (c) IS operator (d) None of these
13. Mandatory argument required to connect any database from python 1
(a) Username, Password, Hostname, Database name, Port
(b) Username, Password, Hostname
(c) Username, Password, Hostname, Database name
(d) Username, Password, Hostname, Port
14. When iterating over an object returned from csv.reader(), what is returned with each iteration? 1
For example, given the following code block that assumes csv_reader is an object returned
from csv.reader(), what would be printed to the console with each iteration?
15. Read the following statement about feature of CSV file and select which statement is TRUE ? 1
Statement 1: Only database can support import/export to CSV format
Statement 2: CSV file can be created and edited using any text editor
Statement 3:All the columns of CSV file can be separated by comma ‘ ,’ only
Page 2 of 8
16. In order to open a connection with MySQL database from within Python using mysql.connector 1
package _________ function is used .
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
(a) Both (A) and (R) are correct and (R) is correct explanation of (A).
(b) Both (A) and (R) are correct and (R) is not the correct explanation of (A).
(c) (A) is True but (R) is False.
(d) (A) is False but (R) is True.
17. Assertion (A) : Data Integrity means that data is accurate and consistent in the database. 1
Reason (R) :- Data integrity also ensures that your data is safe from any outside forces.
18. Assertion (A) : A database can have only one table 1
Reason (R) :- if a piece of data is stored in two places in the database, then storage space is
wasted.
SECTION B
19. Rewrite the following code in python after removing all syntax error(s) . Underline each 2
correction done in the code :-
def sum(c)
s=0
for i in Range (1, c+1)
s=s+i
return s
print(sum(5)
20. Write an advantage and a disadvantage of using Optical fiber cable ? 2
OR
What is the basic difference between functioning of a hub and switch when both precisely
connect computers into a network?
21. What is output of following codes :-
(a) s= ‘My’ 1
s1= ‘Blog’
s2=s[:1] +s1[len (s1)-1:]
print (s2)
22. What is the difference between primary key and unique constraints ? 2
23. (a) Expand the following terms :- 1
(i) SMTP (ii) POP
(b) What is the uses of microwave signals? 1
24. Determine the output of the following :- 2
Page 3 of 8
else:
pass
Table :- LAB
No Itemname CostPerItem Quantity DateofPurchase Warranty Operational
1 Computer 60000 9 21/05/1996 2 7
2 Printer 15000 3 21/05/1997 4 2
3 Scanner 18000 1 29/08/1998 3 1
4 Camera 21000 2 13/06/1996 1 2
5 Hub 8000 1 31/10/1999 2 1
6 UPS 5000 5 21/05/1996 1 4
7 Plotter 25000 2 11/01/2000 2 2
27. Write a function LShift (Arr, n) in Python , which accepts a list Arr of numbers and n is a 3
numeric value by which all elements of the list are shifted to left .
28. Write a function AMCount( ) in Python ,which should read each character of a text file 3
STORY.TXT , should count and display the occurrence of alphabets A and M ( including small
cases a and m also too ).
OR
Write a function in Python that counts the number of “Me” or “My” word present in a text file
“STORY.TXT” , if the “STORY.TXT ” contents are as follows :-
Page 4 of 8
Mt first book
was Me and
My family .It
gave me
chance to be
known to the
world.
30. Write a function in Python , MakePush (Package) and MakePop (Package) to add a new package 3
and delete a package from a List of Package Descriptions , considering them to act as push and
pop operations of the Stack data structure .
OR
Write Addnew(Book) and Remove( Book) functions 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 .
SECTION D
31. (a) Ravya Industries has set up its new center at Kaka Nagar for its office and web based 4
activities . The company compound has 4 buildings as shown in the diagram below :
Raj Fazz
Building Building
Harsh Jazz
Building Building
Page 5 of 8
Center to center distances between various building is as follows :
import random
AR = [20,30,40,50,60,70];
Lower = random.randint (1,3)
Upper= random.randint (2, 4)
For K in range (Lower, Upper +1):
print ( AR [K] , end = “# ”)
(b) Differentiate between fetchone ( ) and fetchcall ( ) method with suitable example for each .
3
OR
(a) Which names are local and which are global in the following code fragment ?
invader= “Big names ” 2
pos = 200
level=1
def play ( ):
max_level= level+10
print(len(invanders) == 0
returnmax_level
res =play ( )
print (res)
Page 6 of 8
33. Ranjan Kumar of class 12 is writing a program to create a CSV file “user.csv” which will 5
contain user name and password for some entries . He has written the following code . As a
programmer, help him to successfully mexecute the given task :
SECTION E
34. A department store MyStore is considering to maintain their inventory using SQL to store the 4
data . As a database administer , Abhay has decided that :-
Table :- STORE
Page 7 of 8
(c) Insert the following data into the attribute ItemNo, ItemName and SCode respectively in the
given table STORE
(d) Abhay want to remove that table STORE from the database MyStore . Which command will
he use from the following :
OR
(d) Now Abhay wants to display the structure of the table STORE ,i.e. name of the attributes and
their respective data types that he has used in the table . Write the query to display the same .
35. Ariba Malik has been given following incomplete code , which takes a student’s details 4
(rollnumber, name and marks ) and writes into a binary file stu.dat using pickling .
import pickle
sturno = int (input (“Enter roll number:=” ))
stuname= input (“Enter name :”)
stumarks= float (input (“Enter marks : ”))
Stu1= {“RollNo. ” : sturno , “Name ” : stuname, “Marks ” : stumarks }
with __________________ as fh : # Fill_Line 1
___________________ # Fill_Line 2
_________________________ as fin : # Fill_Line 3
____________________ # Fill_Line 4
print (Rstu )
if Rstu [“Marks”] >=85:
print (“Eligible for merit certificate ”)
else :
print (“Not eligible for merit certificate ”)
(a) Complete Fill_Line 1 so that the mentioned binary file is opened for writing in fh object
using a with statement.
(b) Complete Fill_Line 2 so that the dictionary Stu’s contents are written on the file opened in
step (a)
(c) Complete Fill_Line 3 so the the earlier created binary file is opened for reading in a file
object namely fin using a with statement.
(d) Complete Fill_Line 4 so that the contents of open file in fin are read into a dictionary namely
Rstu.
************************************
Page 8 of 8
KENDRIYA VIDYALAYA SANGATHAN MUMBAI REGION
Sample Question Paper 2022-23
Marking Scheme
Class- XII
Computer Science (083)
Maximum Marks : 70 Time: 3 Hrs.
SECTION – A
Q.No. Answers Marks
1. State True or False 1
“In Python, a variable is a place holder for data”
Ans:- False
2. Which value type does input() return? 1
(a) Boolean (b) String (c) int (d)float
Ans:- (b) String
3. Which is the correct form of declaration of dictionary? 1
(a) D={1:’M’ , 2: ‘T’ , 3:’W’}
(b) D= {1;’M’ , 2; ‘T’ , 3;’W’}
(c) D= {1:’M’ 2: ‘T’ 3:’W’ }
(d) D= {1:’M’ ; 2: ‘T’ ; 3:’W’}
Ans:- (a) D={1:’M’ , 2: ‘T’ , 3:’W’}
4. How would you write AY in Python as an expression? 1
(a) A*Y (b) A**Y (c) A^Y (d) A^^Y
Ans:- (b) A**Y
5. What is the length of the tuple shown below: - 1
1 | Page
SELECT* FROM Employee;
DML (b) DDL (c) TCL (d) DCL
Ans:- (a) DML
9. Which of the following statements would give an error after executing the 1
following code?
T= ‘green’ # ---- Statement 1
T[0]= ‘G’ #---- Statement 2
T=[1 , ‘B’ ,14.5 ] #---- Statement 3
T[3]=15 #---- Statement 4
Options:-
(a) Statement 2 and 4
(b) Statement 1 and 2
(c) Statement 3 and 4
(d) Statement 1 and 3
Ans:- (a)Statement 2 and 4
10. Fill in the blank: - 1
A---------------------------------- is a property of the entire relation , which
ensures through its value that each tuple is unique in a relation.
(a)Rows (b) key (c) Attribute (d) Field
Ans:- (b) key
11. What will be the output of the following statement in python? (fh is a file 1
handle) fh.seek(-30,2)
Options:- It will place the file pointer:-
(a) at 30th byte ahead of current current file pointer position
(b) at 30 bytes behind from end-of file
(c) at 30th byte from the beginning of the file
(d) at 5 bytes behind from end-of file
Ans:- (b) at 30 bytes behind from end-of file
12. Which of the following keywords will you use in the following query to 1
display the unique values of the column dept_name?
SELECT --------------------- dept_name FROM Company;
(a)All (b) key (c) Distinct (d) Name
Ans:- (c) Distinct
2 | Page
13. The physical address assigned by NIC manufacturer is called-------------- 1
address.
(a)IP (b) MAC (c) TCP (d) URL
Ans:- (b) MAC
14. What will the following expression be evaluated to in Python? 1
(Given values :- A=16 , B=15)
print((14+13%15) +A%B//A)
(a)14 (b) 27 (c) 12 (d) 0
Ans:- (b) 27
15. All aggregate functions except -------------------------ignore null values in 1
their input collection.
(a)max() (b) count(*) (c) Avg() (d) sum()
Ans:- (b) count(*)
16. After establishing database connection, database-------------------- is created 1
so that the sql query may be executed through it to obtain resultset.
(a)connector (b) connection (c) cursor (d) object
Ans:- (c) cursor
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
17. Assertion (A):- A default argument can be skipped in the function call 1
statement.
Reasoning (R):- The default values for parameters are considered only if
no value is provided for that parameter in the function call statement.
Ans:- (a) Both A and R are true and R is the correct explanation for A
18. Assertion (A): CSV files are delimited files that store tabular data where 1
comma delimits every value.
Reason (R): For writing onto a CSV file , user data is written on txt.writer
object which converts the user data into delimited form and writes it on to
the csv file..
3 | Page
SECTION-B
Each question carries 2 marks
19. The following Python code is supposed to print the largest word in a sentence but there are 2
few errors. Rewrite the code after removing errors and underline each corrections made.
Str=input("Enter a sentence")
word=split()
print(word)
maxlen=0
largest=""
for i in word:
l=len(i)
if(l>maxlen):
largest=l
print(largest)
Ans
Str=input("Enter a sentence")
word=Str.split()
print(word)
maxlen=0
largest=""
for i in word:
l=len(i)
if(l>maxlen):
largest=i
maxlen=l
print(largest)
Port Number In general, TELNET uses the port FTP uses port numbers 20
Used number 23 for its command and 21 to establish a
operations. connection and perform file
transfer operations.
4 | Page
Number of Due to single operated port, FTP has two ports
connections TELNET can establish only one available, so it can
connection at a time. establish two connections;
one is for control command
and another is for data
transfer.
Or
Write short notes on URLs and domain names.
Ans:-
A URL (Universal Resource Locator) is a complete web address used to find a particular
web page. While the domain is the name of the website, a URL will lead to any one of the
pages within the website. Every URL contains a domain name, as well as other
components needed to locate the specific page or piece of content.
A domain is the name of a website, a URL is how to find a website, and a website is what
people see and interact with when they get there.
5 | Page
2 It uniquely identifies It refers to the field in a table
a record in the which is the primary key of
relational database another table.
table.
24. What possible outputs are expected to be displayed on the screen at the time of execution of 2
the program from the following code? Also specify the minimum and maximum values that
can be assigned to the variable c.
import random
temp=[10,20,30,40,50,60]
c=random.randint(0,4)
for I in range(0, c):
print(temp[i],”#”)
a) 10#20# b) 10#20#30#40#50#
c) 10#20#30# d) 50#60#
6 | Page
Ans:-
Minimum value of c is 0
Maximum value of c is 4
Possible Answers : 1,2,3
OR
def ChangeLst():
L=[]
L1=[]
L2=[]
for i in range(1,10):
L.append(i)
for i in range(10,1,-2):
L1.append(i)
for i in range(len(L1)):
L2.append(L1[i]+L[i])
L2.append(len(L)-len(L1))
print(L2)
Ans:-
[11, 10, 9, 8, 7, 4]
25. Differentiate between DELETE and DROP table commands with example. 2
Ans:-
Parameter DELETE DROP
7 | Page
Rollback Actions performed by DELETE Actions performed by
can be rolled back as it uses DROP can’t be rolled
buffer. back because it directly
works on actual data.
OR
Table : Car
Ccode CarName Make
501 A-Star Suzuki
503 Indigo Tata
502 Innova Toyota
509 SX4 Suzuki
510 C Class Mercedes
511 I-20 Tata
Table: Customer
Ccode Address
502 Kolkata
509 Jaipur
502 Beas
Ans:-
Ccode CarName Make Address
502 Innova Toyota Beas
502 Innova Toyota Kolkata
509 SX4 Suzuki Jaipur
8 | Page
(b) Write the output of the queries (i) to (iv) based on the table, TRAVEL 2
given below:
Table: TRAVEL
TNO TNAME TDATE KM TCODE NOP
101 Janish 2015-02-18 100 101 32
102 Vedika 2014-06-06 65 101 45
103 Tarun 2012-10-09 32 104 42
104 John 2015-10-30 55 105 40
105 Ahmed 2015-12-15 47 101 16
106 Raveena 2016-02-26 82 103 9
Ans:-
Count(Distinct Tcode)
Ans:-
TCODE MAX(NOP) COUNT(*)
101 45 3
3. Select Tname from TRAVEL where NOP < 20 order by Tname desc;
Ans.
TNAME
Raveena
Ahmed
65
Ans.
def COUNTWORDS( ):
fin=open(‘PYTHON.TXT’, ‘r’)
count=0
for line in fin:
for i in line.split( ):
if i[0].isupper( ):
count+=1
print(count)
fin.close( )
COUNTWORDS( )
OR
Write a python function ALCount(), which should read each character of text
file “STORY.TXT” and then count and display the number of lines which begins
from character ’a’ and ‘l’ individually (including upper cases ‘A’ and ‘L’ too)
Ans.
def ALCount( ):
f = open('STORY.TXT' , 'r' )
10 | Page
countA = 0
countL = 0
for line in f:
if line[0] == 'A' or line[0] == 'a' :
countA+=1
if line[0] == 'L' or line[0] == 'l' :
countL+=1
print('A or a : ', countA)
print('L or l : ', countL)
f.close()
ALCount( )
28. (a) Write the output of SQL queries (i) to (iv) based on table SCHOOLADMIN 3
and ROADMIN, given below:
Table: SCHOOLADMIN
ANO NAME STREAM DOB PHONE FEE
101 Srishti B Business Admin 2005-05-12 12343224 2000
102 Aman Sciences 2005-11-02 67134324 4000
103 Shivam Sciences 2006-01-23 51134324 3500
104 Banita Business Admin 2005-10-12 13241934 2500
105 Myra Fine Arts 2005-07-01 12445931 1500
106 Raghav Humanities 2005-06-05 42155931 5000
107 Medini Fine Arts 2005-09-05 51215931 1000
108 Udai Veer Sciences 2006-11-25 55134324 4500
Table: ROADMIN
R_NO STREAM PLACE
1 Sciences Agra
2 Fine Arts Jaipur
3 Humanities Tinsukia
Ans.
11 | Page
Stream Max(FEE)
Business Admin 2500
Sciences 4500
Fine Arts 1500
Humanities 5000
Ans.
Name Place
Myra Jaipur
Medini Jaipur
(b) Write the command to view the structure of the table ‘ROADMIN’.
12 | Page
Ans. desc ROADMIN;
29. Define a function add( a , b ) where a and b are lists of same length. 3
1. If length of the lists is not equal, function should display a message
‘Length not equal’
2. If length is equal then elements of both the lists should be added together
and form a new list.
For example :
A = [ 1, 2, 3, 4 ]
B= [8,11,27, 14]
C= [ 9, 13, 30, 18 ]
Ans.
def add ( a , b ):
c=[ ]
if len(a) != len(b):
print('Length not equal')
else:
for i in range(len(a)):
c.append(a[i] + b[i] )
print(c)
Write the following user defined functions to perform given operations on the
stack named STUD:
13 | Page
(i) Push_student(s) – To push an object containing SID and Name of
student whose marks are more than 75 to the stack.
(ii) Pop_student( ) – To Pop the objects from the stack and display them.
Also display ‘Stack empty’ when there is no element in the stack.
Ans.
STUD= [ ]
def Push_Student(s):
if s[2] > 75:
L1 = [s[0],s[1]]
STUD.append(L1)
def Pop_student( ):
num=len(STUD)
while len(STUD) ! = 0:
d=STUD.pop()
print(d)
num=num-1
else:
print(“Stack empty”)
(1½ marks for correct push element and 1½ marks for correct pop
element)
OR
Write a function Push(STUD) in python, where STUD is a dictionary containing
The details of stationary items- {Sname : marks}.
The function should push the names of those students in the stack who have
marks less than 33. Also display the count of elements pushed into the stack.
Ans.
Stack= [ ]
def Push(STUD):
cnt= 0
for k in STUD:
if (STUD[k] < 33):
Stack.aappend(k)
Cnt = cnt + 1
print(“ The count of elements =”,cnt)
SECTION – D
31. Bright training institute is planning to set up its centre in Amritsar with four 5
specialised blocks for Medicine, Management, Law courses along with an
Admission block in separate buildings. The physical distance between these
blocks and the number of computers to be installed in these blocks are given
below. You as a network expert have to answer the queries raised by their board
of directors as given in (I) to (IV)
(i) Suggest the most suitable place to install the main server of this
institution to get efficient connectivity.
Ans: Admin Block is the most appropriate place to install the main
server as it has the maximum number of computers.
(ii) Suggest the best wired medium and draw the best cable layout for
effective network connectivity of the blocks having server with all the
other blocks.
15 | Page
( ½ mark for the correct wired medium , ½ mark for correct layout)
Ans. Switch
(1 mark for the correct answer)
(iv) Suggest the most suitable wired medium for efficiently connecting
computers installed in every building out of the following network cables.
● Coaxial cable
● Ethernet cable
● Single pair
● Telephone cable.
(v) Mr X works in the admin block and he usually connects his projector to
his mobile phone for presentation purpose. Identify the type of network
he creates
● PAN
● LAN
● MAN
● WAN
Ans. PAN
(1 mark for the correct answer)
32. (a) Find and write the output of the following Python code: 2
def Show(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
16 | Page
m=m+str[i].upper()
else:
if i%2!=0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Show('CBSE kvs')
Ans. cbse#KVS
(b) The code given below inserts the following record in the table “Library”: 3
BID – integer
BTitle – string
Pages – Integer
Price – Integer
import mysql.connector as mc
def sql_data( ):
con1=mc.connect(host=”localhost”, user=’root’,
password=’kvs’, database=’LIB’)
mycur= ________________________________ # Statement-1
BID=int(input(‘Enter book ID=’))
BTitle=input(‘Enter book title=’)
Pages = int(input(“Enter no. of pages=”))
Price = int(input(“Enter book price=”))
Qry=”insert into library values ( { }, ‘{ }’, { }, { })”. format(BID,
BTitle, Pages, Price)
________________________ # Statement-2
________________________ # Statement-3
print(‘Data added in the table”)
Ans:
Statement-1: con1.cursor()
17 | Page
Statement-2: mycur.execute(Qry)
Statement-3: con1.commit()
OR
(a) Find and write the output of the following python code: 2
def changer(p,q=10):
p=p/q
q=p%q
print(p, '#',q)
return p
a=200
b=20
a=changer(a,b)
print(a,'$',b)
b=changer(b)
print(a,'$',b)
Ans:
10.0 # 10.0
10.0 $ 20
2.0 # 2.0
10.0 $ 2.0
(b) The code given below reads the following record from the table 3
“Library” and display only those records who have price less than 500:
BID – integer
BTitle – string
Pages – Integer
Price – Integer
Ans:
Statement-1: con1.cursor()
Statement-2: mycur.execute(“select * from library where price <
500”)
Statement-3: mycur.fetchall( )
33. Give any one point of difference between ‘writerow ( ) ’ and ‘writerows ( )’ 5
functions.
Write a program in Python that defines and calls the following user defined
functions:
Ans.
The technical difference is that writerow is going to write a list of
values into a single row whereas writerows is going to write multiple
rows from a buffer that contains one or more lists.
Program:
import csv
def ADD( ):
fout = open("shop.csv", 'a', newline= '\n')
wr=csv.writer(fout)
shopno=int(input("Enter Shop No.= "))
19 | Page
name=input("Enter Shop name = ")
address=input("Enter Address= "))
lst=[shopno,name,address] --------- ½ mark
wr.writerow(lst) --------- ½ mark
fout.close()
def COUNTS ():
fin=open("shop.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(len(d))
fin.close()
ADD()
COUNTS()
OR
How rb+ is different from ab+ mode of file handling? 5
Write a program in Python that defines and calls the following user defined
functions:
Ans:
rb+: To open a binary file for both read and write
ab+: To open a binary file for both append and read
Program:
import pickle
def createfile( ):
f = open ( 'record.dat' , 'wb' )
while True:
rno = int ( input ('Enter the roll number : ' ) )
name = input ( 'Enter the name : ' )
clas = int (input ('Enter Class : ') )
section = input ( 'Enter Section : ' )
per = float (input ( ‘Enter percentage : ‘ ) )
20 | Page
record = [rno,name,clas,section,per]
pickle.dump ( record,f )
choice = input ( 'Do you have more records (y/n) : ' )
if choice == 'n' or choice == 'N':
break
f.close( )
def searchRecord(num):
f=open('record.dat','rb+')
found=0
try:
while True:
record = pickle.load ( f )
if record[0] == num:
print(record)
found=1
break
except EOFError:
pass
if found==0:
print('Record not found')
f.close( )
createfile()
rn=int(input(‘Enter roll no. to search=’);
searchRecord(rn)
(1 mark for difference
½ mark for importing pickle module
1½ marks each for correct definition of createfile() and
searchRecord()
½ mark for function call statements)
SECTION -E
Each question carries 4 marks
21 | Page
(a) Identify the attribute best suitable to be declared as a primary key as well
as foreign key.
Ans. empid
(b) Write the degree and cardinality of the table EMPLOYEE.
Ans. Degree – 6
Cardinality - 6
(c) Insert the following data into the attributes EMPID, FIRSTNAME,
LASTNAME, Hire_Date ADDRESS and CITY respectively in the given table
EMPLOYEE.
EMPID=1201, FIRSTNAME=Amit, LASTNAME=Singh, Hire_Date=01-
Aug-2020 ADDRESS=222E South City and CITY= Kolkata.
Ans. INSERT INTO EMPLOYEE values(1201,”Amit”,”Singh”,”2020-08-01”,” 222E South
City”,”Kolkata”)
(d) Abhinay want to remove the table EMPLOYEE from the database db. Which command will
he use.
Ans. Drop table employee;
35. Ratnesh of class 12 is writing a program to create a CSV file “student.csv” which will contain 4
Name, Date of Birth and place. He has written the following code. As a programmer, help him
to successfully execute the given task.
import _______ #Line 1
with open('E:/student.csv',________) as f: #Line 2
w = csv. _______(f) #Line 3
ans= 'y'
while (ans== 'y'):
name= input("Name?: ")
date = input("Date of birth: ")
place = input("Place: ")
w.writerow([name, date, place])
ans=input("Do you want to enter more y/n?: ")
F=open("E:/student.csv", 'r')
reader = csv.________(F) #Line 4
22 | Page
for row in reader:
print(row)
F._______( ) #Line 5
(a) Name the module he should import in Line 1.
Ans. CSV
(b) In which mode, Ratnesh should open the file to add data into the file.
Ans. a or a+
(c) Fill in the blank in Line 3 to write the data to the csv file.
Ans. writer
(d) Fill in the blank in Line 4 to read the data from a csv file.
Ans. reader
23 | Page
KENDRIYA VIDYALAYA SANGATHAN MUMBAI REGION
Sample Question Paper 2022-23
Class- XII
Computer Science (083)
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.
8. All programming questions are to be answered using Python Language only.
SECTION – A
Q.No. QUESTIONS Marks
1 | Page
8. Consider the following Sql statement . What type of statement is this? 1
SELECT* FROM Employee;
(a) DML (b) DDL (c) TCL (d) DCL
9. Which of the following statements would give an error after executing the 1
following code?
T= ‘green’ # ---- Statement 1
T[0]= ‘G’ #---- Statement 2
T=[1 , ‘B’ ,14.5 ] #---- Statement 3
T[3]=15 #---- Statement 4
Options:-
(a) Statement 2 and 4
(b) Statement 1 and 2
(c) Statement 3 and 4
(d) Statement 1 and 3
10 Fill in the blank: - 1
A---------------------------------- is a property of the entire relation , which ensures
through its value that each tuple is unique in a relation.
(a)Rows (b) key (c) Attribute (d) Field
11 What will be the output of the following statement in python? (fh is a file handle) 1
fh.seek(-30,2)
Options:-
It will place the file pointer:-
(a) at 30th byte ahead of current current file pointer position
(b) at 30 bytes behind from end-of file
(c) at 30th byte from the beginning of the file
(d) at 5 bytes behind from end-of file
12 Which of the following keywords will you use in the following query to display 1
the unique values of the column dept_name?
SELECT --------------------- dept_name FROM Company;
(a)All (b) key (c) Distinct (d) Name
13 The physical address assigned by NIC manufacturer is called--------------address. 1
(a)IP (b) MAC (c) TCP (d) URL
2 | Page
14 What will the following expression be evaluated to in Python? 1
(Given values :- A=16 , B=15)
print((14+13%15) +A%B//A)
SECTION – B
Each question carries 2 marks
19. The following Python code is supposed to print the largest word in a sentence 2
but there are few errors. Rewrite the code after removing errors and underline
each corrections made.
Str=input("Enter a sentence")
word=split()
print(word)
3 | Page
maxlen=0
largest=""
for i in word:
l=len(i)
if(l>maxlen):
largest=l
print(largest)
24. What possible outputs are expected to be displayed on the screen at the time of 2
execution of the program from the following code? Also specify the minimum and
maximum values that can be assigned to the variable c.
import random
temp=[10,20,30,40,50,60]
c=random.randint(0,4)
for I in range(0, c):
print(temp[i],”#”)
a) 10#20# b) 10#20#30#40#50#
c) 10#20#30# d) 50#60#
OR
def ChangeLst():
4 | Page
L=[]
L1=[]
L2=[]
for i in range(1,10):
L.append(i)
for i in range(10,1,-2):
L1.append(i)
for i in range(len(L1)):
L2.append(L1[i]+L[i])
L2.append(len(L)-len(L1)
print(L2)
25. Differentiate between DELETE and DROP table commands with example. 2
OR
Categorize the following commands as DDL or DML:
INSERT, DESC, ALTER, DELETE
SECTION – C
26. (a) Based on the tables CAR and CUSTOMER write the output of the 1+2
following query:
Table : Car
Ccode CarName Make
501 A-Star Suzuki
503 Indigo Tata
502 Innova Toyota
509 SX4 Suzuki
510 C Class Mercedes
511 I-20 Tata
Table: Customer
Ccode Address
502 Kolkata
509 Jaipur
502 Beas
(b) Write the output of the queries (i) to (iv) based on the table, TRAVEL
given below:
Table: TRAVEL
TNO TNAME TDATE KM TCODE NOP
101 Janish 2015-02-18 100 101 32
102 Vedika 2014-06-06 65 101 45
103 Tarun 2012-10-09 32 104 42
104 John 2015-10-30 55 105 40
5 | Page
105 Ahmed 2015-12-15 47 101 16
106 Raveena 2016-02-26 82 103 9
27. Write a function countwords( ) that read a file ‘python.txt’ and display the total 3
number of words which begins by uppercase character.
Example:
OR
Write a python function ALCount(), which should read each character of text
file “STORY.TXT” and then count and display the number of lines which begins
from character ’a’ and ‘l’ individually (including upper cases ‘A’ and ‘L’ too)
Example:
A python is a powerful
Language is user friendly
It is platform independent Language
28. (a) Write the output of SQL queries (i) to (iv) based on table SCHOOLADMIN 3
and ROADMIN, given below:
Table: SCHOOLADMIN
ANO NAME STREAM DOB PHONE FEE
101 Srishti B Business Admin 2005-05-12 12343224 2000
102 Aman Sciences 2005-11-02 67134324 4000
103 Shivam Sciences 2006-01-23 51134324 3500
104 Banita Business Admin 2005-10-12 13241934 2500
105 Myra Fine Arts 2005-07-01 12445931 1500
106 Raghav Humanities 2005-06-05 42155931 5000
6 | Page
107 Medini Fine Arts 2005-09-05 51215931 1000
108 Udai Veer Sciences 2006-11-25 55134324 4500
Table: ROADMIN
R_NO STREAM PLACE
1 Sciences Agra
2 Fine Arts Jaipur
3 Humanities Tinsukia
(b) Write the command to view the structure of the table ‘ROADMIN’
29. Define a function add( a , b ) where a and b are lists of same length. 3
1. If length of the lists is not equal, function should display a message
‘Length not equal’
2. If length is equal then elements of both the lists should be added together
and form a new list.
For example :
A = [ 1, 2, 3, 4 ]
B= [8,11,27, 14]
C= [ 9, 13, 30, 18 ]
Write the following user defined functions to perform given operations on the
stack named STUD:
(ii) Pop_student( ) – To Pop the objects from the stack and display them.
Also display ‘Stack empty’ when there is no element in the stack.
OR
7 | Page
SECTION – D
31. Bright training institute is planning to set up its centre in Amritsar with four 5
specialised blocks for Medicine, Management, Law courses along with an
Admission block in separate buildings. The physical distance between these
blocks and the number of computers to be installed in these blocks are given
below. You as a network expert have to answer the queries raised by their board
of directors as given in (I) to (IV)
(i) Suggest the most suitable place to install the main server of this institution
to get efficient connectivity.
(ii) Suggest the best wired medium and draw the best cable layout for effective
network connectivity of the blocks having server with all the other blocks.
(iii) Suggest the devices to be installed in each of these buildings for connecting
computers installed within the building out of the following:
● Modem
● Switch
● Gateway
● Router
(iv) Suggest the most suitable wired medium for efficiently connecting
computers installed in every building out of the following network cables.
● Coaxial cable
● Ethernet cable
● Single pair
● Telephone cable.
8 | Page
(v) Mr X works in the admin block and he usually connects his projector to his
mobile phone for presentation purpose. Identify the type of network he
creates
● PAN
● LAN
● MAN
● WAN
32. (a) Find and write the output of the following Python code: 2+3
def Show(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)
Show('CBSE kvs')
(b) The code given below inserts the following record in the table “Library”:
BID – integer
BTitle – string
Pages – Integer
Price – Integer
import mysql.connector as mc
def sql_data( ):
con1=mc.connect(host=”localhost”, user=’root’,
password=’kvs’, database=’LIB’)
mycur= ________________________________ # Statement-1
BID=int(input(‘Enter book ID=’))
BTitle=input(‘Enter book title=’)
9 | Page
Pages = int(input(“Enter no. of pages=”))
Price = int(input(“Enter book price=”))
Qry=”insert into library values ( { }, ‘{ }’, { }, { })”. format(BID,
BTitle, Pages, Price)
________________________ # Statement-2
________________________ # Statement-3
print(‘Data added in the table”)
OR
(a) Find and write the output of the following python code:
def changer(p,q=10):
p=p/q
q=p%q
print(p,’#’,q)
return p
a=200
b=20
a=changer(a,b)
print(a,’$’,b)
b=changer(b)
print(a,’$’,b)
(b) The code given below reads the following record from the table
“Library” and display only those records who have price less than 500:
BID – integer
BTitle – string
Pages – Integer
Price – Integer
import mysql.connector as mc
def sql_data( ):
con1=mc.connect(host=”localhost”, user=’root’,
password=’kvs’, database=’LIB’)
mycur= ________________________________ # Statement-1
10 | Page
print(“Books with price less than 500 are: ”)
________________________ # Statement-2
33. Give any one point of difference between ‘writerow ( ) ’ and ‘writerows ( )’ 5
functions.
Write a program in Python that defines and calls the following user defined
functions:
OR
Write a program in Python that defines and calls the following user defined
functions:
SECTION – E
Each question carries 4 marks
11 | Page
(a) Identify the attribute best suitable to be declared as a primary key as well
as foreign key.
(b) Write the degree and cardinality of the table EMPLOYEE.
(c) Insert the following data into the attributes EMPID, FIRSTNAME,
LASTNAME, Hire_Date ADDRESS and CITY respectively in the given table
EMPLOYEE.
EMPID=1201, FIRSTNAME=Amit, LASTNAME=Singh, Hire_Date=01-
Aug-2020 ADDRESS=222E South City and CITY= Kolkata.
(d) Abhinay want to remove the table EMPLOYEE from the database db.
Which command will he use.
35. Ratnesh of class 12 is writing a program to create a CSV file “student.csv” which will 4
contain Name, Date of Birth and place. He has written the following code. As a
programmer, help him to successfully execute the given task.
import _______ #Line 1
with open('E:/student.csv',________) as f: #Line 2
w = csv. _______(f) #Line 3
ans= 'y'
while (ans== 'y'):
name= input("Name?: ")
date = input("Date of birth: ")
place = input("Place: ")
w.writerow([name, date, place])
ans=input("Do you want to enter more y/n?: ")
F=open("E:/student.csv", 'r')
reader = csv.________(F) #Line 4
for row in reader:
print(row)
F._______( ) #Line 5
(a) Name the module he should import in Line 1.
(b) In which mode, Ratnesh should open the file to add data into the file.
(c) Fill in the blank in Line 3 to write the data to the csv file.
(d) Fill in the blank in Line 4 to read the data from a csv file.
12 | Page
13 | Page
Class: XII Session: 2022-23
Computer Science (083)
Sample Question Paper (Theory)
---------------------------------------------------------------------------------------------------------------------------------------------------
SECTION A
1 In a Python program, a control structure: 1marks
(A) Defines program-specific data structre each
(B) Directs the order of Execution of statements in the program
(C) Dictates what happens before the program starts and after it terminates
(D) None of above
ANS : B
2 Find the invalid Identifier from the following: 1marks
(A) Myname each
(B) 1Myname
(C) My_name
(D) Myname2
ANS : B
3 Which of the following is invalid method for fetching the records from database 1marks
within Python ? each
(A) fetchone()
(B) fetchmany()
(C) fetchall()
(D) fetchmulti()
ANS : D
4 What is the default EOL Character in python ? 1marks
(A) \n (B) \t (C) \l (D) \h each
ANS : A
5 This method is used to load (unpickling) data from binary file 1marks
(A) load() (B) dump() (C) seek() (D) tell() each
ANS : A
ANS : C
11 State true or false 1marks
“ Immutable data type are those that can never change their values “ each
ANS TRUE
12 Which of the following statement(s) would give an error after executing the 1marks
following code? each
x=50 # Statement 1
Def func(x) # Statement 2
x=2 # Statement 3
func(x) # Statement 4
print(x) # Statement 5
ANS : D
13 which of the following is the correct output for executing the following python 1marks
statement? each
print(5 + 3**2 / 2)
(A) 32 (B) 8.0 (C) 9.5 (D) 32.0
ANS : C
1marks
14 Which topology is based on a central node which acts as a hub ? each
(A) Bus topology (B) Star topology
(C) Tree topology (D) Hybrid Topology
ANS : B
1marks
15 To establish a connection between Python and SQL database, what of the each
following statement is connecting database server?
(A) importMySQLdb
(B) MySQLdb.connect
(C) db.cursor
(D) None of the above
ANS : B
16 _______function place the pointer at the specified position of the file pointer by 1marks
in an opening file. each
18 Assertion (A): CSV (Comma Separated Values) is a file format for data storage 1marks
which looks like a text file. each
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 What possible outputs(s) are expected to be displayed on screen at the time of 1marks
execution of the program from the following code? Also specify the maximum for each
values that can be assigned to each of the variables Lower and Upper. correct
import random answer
AR=[20,30,40,50,60,70];
Lower=random.randint(1,3)
Upper=random.randint(2,4)
for K in range(Lower, Upper+1):
print (AR[K],end="#")
(A) 10#40#70#
(B) 30#40#50#
(C) 50#60#70#
(D) 40#50#70#
ans : (B)
Maximum value that assigned to Lower and Upper is 3 and 4 respectively
Ans :
300 @ 200
300 # 100
150 @ 100
300 @ 150
22 Rewrite the following code in Python after removing all syntax error(s). 2
Underline each correction done in the code.
30= Value ½ marks
for VAL in range(0,Value) for each
If val%4=0: correct
print (VAL*4) row
Else val%5==0:
print (VAL+3)
Ans :
Value=30
for VAL in range(0,Value) :
if val%4 = = 0:
print (VAL*4)
else val%5==0:
print (VAL+3)
Ans: (a) @@2202 puC’W 02T ## 1 marks for each correct row
(b) Ans: dict_items([('name', 'Aman'), ('age', 27), ('address', 'Delhi')])
Name gname
Rohan Football
Rohan Lawn Tennis
Jaya Football
Jaya Lawn Tennis
Teena Football
Teena Lawn Tennis
B. i) 1200000
ii) 4500
iii) 2
iv) All given table data will display.
27 def countH( ):
f = open(“Para.txt”, “r”)
lines = 0
l = f.readlines( )
for i in l:
if[0] ==’H’:
lines+=1
print(“No of lines are”, lines)
f.close( )
or
def countmy( ):
f = open(“DATA.txt”, “r”)
count= 0
x = f.read( )
word = x.split( )
for i in word:
if( i== “my”)
count = count + 1
print(“my occurs”, count, “Times”)
f.close( )
28. a) i) Name
Motherboard
Hard Disk
LCD
ii) Area Count
CP 2
GK II 1
Nehru Place 2
iii) Count(Distinct Area)
3
iv) Name Price
Motherboard 12000
Motherboard 13000
def Display(stk):
if isEmpty(stk):
print(“Stack Empty”)
else:
top = len(stk) – 1
print(stk[top],”top”]
for a in range (top -1, -l,-1):
print(stk[a])
or
def MakePush(Package):
a = int(input(“Enter package title:”))
Package.append(a)
def MakePop(Package):
if (Package===[]):
print(“Stack Empty”)
else:
print(“Deleted element:”, Package.pop( ))
SECTION D
31 i) Bus Topology
Resource
Main
Building Building
Training Accounts
Building Building
b) i)mycon
ii)db.cursor()
iii)db.close()
or
a) SCHOOLbbbbCOM
b) i)statement1 – import mysql.connector
ii) cursor = db.cursor() #statement2
iii) cursor.execute(sql) #statement3
csv_w.writerow(row)
or
difference between text and csv file (1marks)
def addCsvFile(Username, Password):
f= open(‘user.csv’,’a’)
newFileWriter=csv.writer(f)
newFileWriter.writerow([username,password])
f.close( )
def readCvsFile():
with open(‘user.csv’,’r’) as newFile:
for row in newFileReader:
print(row[0],row[1])
newFile.close( )
SECTION E
34. a. primary key – ItemNo
b. Degree – 4, Cardinality – 6
c. i) insert into STORE values(2010,”Note Book”,25,50);
ii)update store set quantity = quantity + 10;
or
c. i) delete * from STORE WHERE ItemNo=2005;
ii) alter table STORE add(price float(5));
SECTION A
1 In a Python program, a control structure: 1
(A) Defines program-specific data structre
(B) Directs the order of Execution of statements in the program
(C) Dictates what happens before the program starts and after it terminates
(D) None of above
2 Find the invalid Identifier from the following: 1
(A) Myname
(B) 1Myname
(C) My_name
(D) Myname2
3 Which of the following is invalid method for fetching the records from database 1
within Python ?
(A) fetchone()
(B) fetchmany()
(C) fetchall()
(D) fetchmulti()
13 which of the following is the correct output for executing the following python 1
statement?
print(5 + 3**2 / 2)
(A) 32 (B) 8.0 (C) 9.5 (D) 32.0
1
14 Which topology is based on a central node which acts as a hub ?
(A) Bus topology (B) Star topology
(C) Tree topology (D) Hybrid Topology
1
15 To establish a connection between Python and SQL database, what of the following
statement is connecting database server?
(A) importMySQLdb
(B) MySQLdb.connect
(C) db.cursor
(D) None of the above
16 _______function place the pointer at the specified position of the file pointer by in 1
an opening file.
(A) 10#40#70#
(B) 30#40#50#
(C) 50#60#70#
(D) 40#50#70#
20 (a) Write the full form of the following 2
i) ARPANET ii) WiMax
table : games
gameno gname
10 Football
11 Lawn Tennis
b) write the output of queries i) to iv) based on the table, LOANS given below:
Table : LOANS
27 Write a user – defined function countH() in Python that displays the number of lines 3
. starting with ‘H’ in the file ‘Para.txt”. Example , if the file contains:
Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.
Output: The line count should be 2.
OR
Write a function countmy() in Python to read the text file “DATA.TXT” and count
the number of times “my” occurs in the file. For example , if the file “DATA.TXT”
contains –
“This is my website. I have displayed my preference in the CHOICE section.” The
countmy( ) function should display the output as:
“my occurs 2 times”
28 Write the output of the SQL queries i) to iv) based on the relations SHOP and 2+1
. ACCESSORIES given below:
Table: SHOP
Id SName Area
S01 ABC Computronics CP
S02 All Infotech Media GK II
S03 Tech Shopee CP
S04 Geek Tenco Soft Nehru Place
S05 Hitech Tech Store Nehru Place
Table : ACCESSORIES
No Name Price Id
A01 Motherboard 12000 S01
A02 Hard Disk 5000 S01
A03 Keyboard 500 S02
A04 Mouse 300 S01
A05 Motherboard 13000 S02
A06 Keyboard 400 S03
A07 LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T010 Hard Disk 450 S03
Expected Result:[2,4,6,8]
30 Write a program to implement a Stack for these book-details(book no, book name). 3
. That is , now each item node of the stack contains two types of information – a book
no, and its name. Just implement PUSH and Display Operations create a Push() and
Display() functions:
OR
Write a function in Python MakePush(Package) and MakePop(Package) to add a
new Package and delete a Package from a List of package description, considering
them to act as puch and pop operations of the Stack data structure.
SECTION D
31 “Vidya for All” is an educational NGO. It is setting up its new campus at Jaipur for 5
. its web-based activities. The campus has four building as shown in diagram below:
Main Resource
Building
Building
Training Accounts
Building Building
Center to Center distance between various building as per architectural drawings (in
meters is as follows:
Main Building to Resource Building 120m
Main Building to Training Building 40m
Main Building to Accounts building 135m
Resource Building to Training Building 125m
Resource Building to Account Building 45m
Training building to Account Building 110m
Main Building 15
Resource Building 25
Training Building 250
Accounts Building 10
b.) study the database ‘company’ that has a table ‘Emp’ that stores IDs of
employees. Code contain the connectivity to retrieve data, one record at a time, for
employees with IDs less than 10.
Write the missing statements
i)Statement1 .
ii)Statement2
iii)Statement3
OR
a)Predict the output of the following 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].isalpha( ):
m=m+s[i].upper( )
else:
m = m + ‘bb’
print(m)
fun(‘school2@com’)
b)Consider the following code which is doing following ,
updating the records of employees by increasing the salary by Rs.1000 of all those
employees who are getting less than Rs. 80000.
Write the following missing statements:
i)statement1
ii)statement2
iii)statement3
try:
cursor._______________ #statement3
bd1.commit( )
except:
db1.rollback( )
bd1.close( )
33 Write a user defined function to perform read and write operations onto a 5
. ‘student.csv’ file having fields roll number, name, stream and marks.
Or
Based on the above STOR Table and data in it answer the following questions:
35 Vishal has been given following incomplete code which takes a students details 1+1+1+
. (rollnumber, name and marks) and writes into binary file stu.dat using pickling. 1
Print(Rstu)
if Rstu[“Marks”] >= 85:
print(“Eligible for merit certificate”)
else:
print(“Not Eligible for merit certificate”)