Class 12 Cs KV Region Pb1 Papers 2023-24
Class 12 Cs KV Region Pb1 Papers 2023-24
Class 12 Cs KV Region Pb1 Papers 2023-24
SECTION A
(No marks for partially correct answers)
Q1 b) 1026 1
Q2 c) True 1
Q3 a) iai pa 1
Q4 a) list 1
Q5 c) d.clear( ) 1
Q6 d) None 1
Q7 c) t[3] = 300 1
Q8 d) $ 1
Q9 b) Optic Fiber 1
Q10 b) RJ45 1
Q11 a) select gender, count(*) form students having age >15; 1
Q12 b) UPDATE 1
Q13 c) 8, 24 1
Q14 b) bps 1
Q15 d) except 1
Q16 a) F = open(‘story.txt’, ‘read’) 1
d) Open(F) = ‘story.txt’
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
Page 1 of 7
Q18 a) Both A and R are true and R is the correct explanation for A 1
SECTION B
Q19 a) 2
Page 2 of 7
SECTION C
Q26 @@@NNew@MMen 3
Q27 i. 1x3
Name Salary =3
PV Sindhu Badminton
Saina Nehwal Badminton
Pankaj Advani Snooker
V Anand Hockey
ii.
sum(Salary)
22500
iii.
count(distinct Game)
5
Page 3 of 7
f.close()
return c #print(c)
Q29 i. UPDATE Employees SET salary = salary + salry*0.1 WHERE gender = ‘F’; 3
ii. SELECT name, gender from Employees WHERE salary is NULL;
iii. DELETE from Employees WHERE dob<’1995-01-01’;
def Pop_items():
try:
item = items.pop()
print(item)
except:
print(“Stack Empty”)
def highestAverage():
Page 4 of 7
max_average = 0
best_player = ''
with open('FOOTBALL.CSV', 'r') as csvfile:
reader = csv.reader(csvfile)
next(reader) # Skip the header row if it exists
for row in reader:
name, matches, goals = row[0], int(row[1]), int(row[2])
if matches > 0:
average = goals / matches
if average > max_average:
max_average = average
best_player = name
if best_player:
print(best_player)
else:
print("No player data found in the CSV file.")
SECTION E
Q33 a) Tagore, as it has maximum number of computers. Housing the server here will reduce 1x5
the external traffic. =5
b) Firewall S
c) Ethernet Cable T R
25 m
90 m
A
75 m
Page 5 of 7
Q34 (i) 1 Mark for 1 difference point 2+3
=5
(ii)
import pickle
def search(app):
f = open(‘PASSWORDS.DAT’, ‘rb’)
while True:
try:
obj = pickle.load(f)
if obj[0] == app:
print(obj)
break
except:
break
f.close()
OR
(i) rb, rb+ will give error, while ab and wb+ modes will create the file (1/2 mark each)
(ii)
import pickle
def filterStudents(clas, sec):
fin = open('STUDENTS.DAT', 'rb')
fout = open('FILTERED.DAT', 'wb')
while True:
try:
stu = pickle.load(fin)
if stu[2] == clas and stu[3] == sec:
pickle.dump(stu, fout)
except:
break
Page 6 of 7
Q35 (i) ½ + ½ 1+4
=5
import mysql.connector as ms
conn = ms.connect(host="localhost",
user="heerakh",
passwd='happy',
db='sports')
cur = conn.cursor()
pid = int(input("Enter player ID : "))
pname = input("Enter name : ")
inn = int(input("Enter innings : "))
runs = int(input("Runs Scored : "))
wickets = int(input("Wickets : "))
query = f"insert into cricket values({pid}, '{pname}', {innings}, {runs}, {wickets})"
try:
cur.execute(query)
print("Row inserted")
except:
print("SQL Error")
conn.close()
OR
(i) ½ + ½
(ii)
import mysql.connector as ms
conn = ms.connect(host="localhost",
user="keshav",
passwd='karma',
db='sports')
cur = conn.cursor()
query = "select pname from cricket where innings>100"
cur.execute(query)
for row in cur.fetchall():
print(row[0])
conn.close()
Page 7 of 7
12COM03QP
KENDRIYA VIDYALAYA SANGATHAN , CHENNAI REGION
PRE-BOARD-I EXAMINATION 2023-2024
CLASS XII-COMPUTER SCIENCE (083)
TIME: 03 HOURS M.M.: 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 01mark 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 02 Long Answer type questions carrying 04 marks each.
7. Section E has 03 questions carrying 05 marks each.
8. All programming questions are to be answered using Python Language only.
SECTION A
1. Assign a tuple containing an Integer? (1)
(a) File pointer will move10 byte in forward direction from beginning of the file
(b) File pointer will move 10 byte in forwarddirection from end of the file
(c) File pointer will move 10 byte inforwarddirection from current location
(d) File pointer will move 10 byte in backward direction from current location
7. Choose correct SQL query which is expected to delete all rows of a table emp without (1)
deleting its structure.
a) DELETE TABLE;
b) DROP TABLE emp;
c) REMOVE TABL emp;
d) DELETE FROM emp;
8. Which of the following is NOT a DML Command? (1)
(a)Insert (b)Update (c)Drop (d)Delete
9. Select the correct outpu to the code: (1)
a="Year2022atallthe best"
a=a.split('a')
b=a[0]+"-"+a[1]+"-"+a[3]
print (b)
a) Year–0-atAllthebest
b) Ye-r2022-llthe best
c) Year–022-at Allthebest
d) Year–0-atallthebest
10. Which of the following statement(s) would give an error during execution?
S="Lucknow is the Capital of UP " #Statement1
print(S) #Statement2
S[4]='$’ #Statement3
S="Thankyou" #Statement4
S=S+"Thankyou" #Statement5
17. Assertion (A):-The default arguments can be skipped in the function call. (1)
Reason (R):-The function argument will take the default values even if the values are
supplied in the function call
18. Assertion(A):A tuple can be concatenated to a list,but a list cannot be concatenated to a (1)
tuple.
Reason(R):Lists are mutable and tuples are immutable in Python.
SECTION B
19. Ravi has written a function to print Fibonacci series for first 10 element. His code is
having errors. Rewrite the correct code and underline the corrections made. Some initial
(2)
elements of Fibonacci series are:
def fibonacci()
first=0
second=1
print((“first no. is “, first)
print(“secondno.is,second)
for a in range (1,9):
third=first+second
print(third)
first,second=second,third
fibonacci()
20. What possible outputs (s) are expected to be displayed on screen at the time of (2)
execution of the program from the following code? Also specify the maximum values
that can be assigned to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70]
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print(AR[K],end=” #“ )
OR
def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('Fun@World2.0')
25. Consider the following two commands with reference to a table, named Students, (2)
having a column named Section:
(a) Select count(Section)from Students;
(b) Select count(*)from Students;
If these two commands are producing different results,
(i) What may be the possible reason?
(ii) Which command,(a)or(b),might be giving higher value?
OR
Name the aggregate functions which work only with numeric data, and those that work
with any type of data.
SECTION C
26. (a)Consider the following tables– EMPLOYEES AND DEPARTMENT (1)
Write a function in python to count the number of lines in a text file ‘Country.txt’
which are starting with an alphabet ‘W’ or ‘H’.
For example,If thef ile contents are as follows:
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.
The output of the function should be:
W or w:1 H or
h:2
28. Consider the following tables GAMES. Give outputs for SQL queries (i)to(iv). (2+
1)
Table:GAMES
The function should push the names of those items in a stack which have price less
than 100. Also display the average price of elements pushed into the stack.
For example: If the dictionary contains the following data:
{"Spoons":116,"Knife":50,"Plates":180,"Glass":60}
He now has to delete a record based on the employee id entered by the user. For
this purpose, he creates a temporary file, named temp.dat, to store all the records
other than the record to be deleted. If the employee id is not found, an appropriate
message should to be displayed.
As a Python expert, help him to complete the following code (by completing
statements 1, 2, 3, and 4) based on the requirement given above:
import #Statement1
def update_data():
rec={} fin=open("record.dat","rb")
fout=open(" ","") #Statement2
found=False
eid=int(input("Enter employee id:")) while True:
try:
rec= #Statement3
if rec["Employee id"]==eid:
found=Tru
e else:
#Statement 4
except:
break
if found==True:
print("Recorddeleted.")
else:
print("Employee with such id is notfound")
fin.close()
fout.close()
32. A departmental store MyStore is considering to maintain their inventory using 4
SQL to store the data. As a database Administrator, Abhay has decided that:
Name of the database–mystore
Name of the table –STORE
The attributes of STORE are as follows
ItemNo –numeric
ItemName–character of size 20
Scode – numeric
Quantity– numeric
Table : STORE
ii) Now Abhay wants to display the structure of the table STOREi.e.name of
the attributes and their respective data types that he has used in the table.
Write the query to display the same.
OR
(i) Abhay wants to ADD a new column price with data type as decimal. Write
the query to add the column..
(ii) Now Abhay wants to remove a column price from the table STORE.Write the
query.
SECTION E
33.
A company ABC Enterprises has four blocks of buildings as shown :
B1 B2
B3 B4.
Number of computers:
(b) The code given below reads records from the table named student and displays only
those records who have marks greater than 75.The structure of a record of table (4)
Student is:
RollNo–integer;Name –string;Clas –integer;Marks– integer
35. (i) Write one similarity and one difference between a+ and w+ (2+
(ii) A binary file “emp.dat” has structure (EID, Ename, designation,salary) 3)
Write a function Show() in Python that would read the details of employees from the
file “emp.dat” and display the details of those employees whose designation is
“Manager”
(OR)
(i) What is the difference between readline() and readlines() ?
(ii) A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price].
Write a function CountRec(Author) in Python which accepts the Author name
as parameter and count and return number of books written by the given Author
****END****
PB23CS01
SECTION - A
1 Which of the following is a keyword in Python?
a) true b) For c) pre-board d) False 1
1
Tuple2=Tuple1*2
print(Tuple2)
a) 20 b) (20,) c) (10,10) d) Error
8 Fill in the blanks:
The SQL keyword ---------------- is used in SQL expression to select records 1
based on patterns
9 What possible outcome will be produced when the following code is executed?
import random
value=random.randint(0,3)
fruit=["APPLE","ORANGE","MANGO","GRAPE"]
for i in range(value):
print(fruit[i],end='##')
print()
a) APPLE##
1
b) APPLE#
ORANGE##
c) APPLE## ORANGE##
d) ORANGE##
MANGO##
APPLE##
10 Select the network device from the following, which connects, networks with
different protocols 1
a) Bridge b)Gateway c)Hub d) Router
11 State whether the following statement is TRUE or FALSE :
1
The value of the expression 4/3*(2-1) and 4/(3*(2-1)) is the same
12 In the relational models , cardinality actually refers to --------------
a) Number of tuples b) Number of attributes 1
c) Number of tables d) Number of constraints
13 Data structure STACK is also known as ----------- list
a)First In First Out b) First In Last Out 1
c)Last In First Out d) Last In Last Out
14 Which function is used to write a list of strings in a file?
1
a) writeline( ) b) writelines( ) c) write() d) writeall( )
15 Which of the following is NOT a guided communication medium?
a) Twisted pair cable b) Microwave 1
c) Coaxial cable d) Optical fibre
16 Which of the following function header is correct?
a) def fun(a=1,b):
b) def fun(a=1,b,c=2): 1
c) def fun(a=1,b=1,c=2):
d) def fun(a=1,b=1,c=2,d):
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
2
(d) A is false but R is True
17 Assertion ( A): In SQL, the aggregate function avg() calculates the average
value on a set of values and produces a single result.
Reason ( R): The aggregate functions are used to perform some fundamental 1
arithmetic tasks such as min(), max(), sum() etc
SECTION - B
19 i) Expand the following :
a) SMTP b) VoIP
ii) Give one disadvantage of Star topology
1+1=2
OR
i) What is a web browser ?
ii) Define the term MAC Address
20 Rewrite the following code in Python after removing all syntax error(s) and
underline each correction done in the code .
30 = num
for k in range(0,num)
2
IF k%4==0 :
print(k*4)
Else:
print(k+3)
21 Write a function letter_count(lst) that takes a list of string and returns a
dictionary where the keys are the letters from lst and the values are the number
of times that letter appears in the lst.
For example: if the passed list, lst is :
lst=list(“apple”)
2
Then it should return a dictionary as {‘a’:1,’p’:2,’l’:1,’e’:1}
OR
Write a function max_length( ) ,that takes a list of string as argument and
display the longest string from the list.
lst=[2,4,6,8,10]
for i in range(1,5):
2
lst[i-1]=lst[i]
for i in range(0,5):
print(lst[i],end=' ')
23 Consider the following list of elements and write Python statement to print the
output of each question.
elements=['apple',200,300,'red','blue','grapes'] 2
i) print(elements[3:5])
ii) print(elements[::-1])
3
OR
Consider the following list exam and write Python statement for the following
questions:
exam=[‘english’,’physics’,’chemistry’,’cs’,’biology’]
i) To insert subject “maths” as last element
ii) To display the list in reverse alphabetical order
24 Satheesh has created a database “school” and table “student”. Now he wants to
view all the databases present in his laptop. Help him to write SQL command
for that , also to view the structure of the table he created.
OR
2
Meera got confused with DDL and DML commands. Help her to select only
DML command from the given list of command.
UPDATE , DROP TABLE, SELECT , CREATE TABLE , INSERT INTO,
DELETE , USE
25 Predict the output for the following Python snippet
def calc(p,q=3):
ans=1
for x in range(q):
ans=ans*p 2
return ans
power=calc(3)
print(power,'9')
power=calc(3,2)
print(power,'27')
SECTION C
26 Predict the output of the Python code given below:
def calculate(str):
text=''
x=range(len(str)-1)
for i in x:
if str[i].isupper():
text+=str[i]
elif str[i].islower(): 3
text+=str[i+1]
else:
text+='@'
return text
start='Pre-board Exam'
final=calculate(start)
print(final)
4
27 Consider the following table DOCTOR given below and write the output of the
SQL Queries that follows :
28 Write a function in Python to count the number of lines in a text fie ‘EXAM.txt’
which start with an alphabet ‘T’ .
OR 3
Write a function in Python that count the number of “can” words present in a
text file “DETAILS.txt” .
29 Consider the following Table “TEACHER”
Based on the above table, Write SQL command for the following :
i) To show all information about the teacher of maths department
ii) To list name and department whose name starts with letter ‘M’
iii) To display all details of female teacher whose salary in between
35000 and 50000
5
30 Thushar received a message(string) that has upper case and lower-case alphabet.
He want to extract all the upper case letters separately .Help him to do his task
by performing the following user defined function in Python:
a) Push the upper case alphabets in the string into a STACK
3
b) Pop and display the content of the stack.
For example:
If the message is “All the Best for your Pre-board Examination”
The output should be : E P B A
SECTION D
31 Consider the table PRODUCT and CLIENT given below:
PRODUCT
PR_ID PR_NAME MANUFACTURER PRICE QTY
BS101 BATH SOAP PEARSE 45.00 25
SP210 SHAMPOO SUN SILK 320.00 10
SP235 SHAMPOO DOVE 455.00 15
BS120 BATH SOAP SANTOOR 36.00 10
TOOTH
TB310 COLGATE 48.00 15
BRUSH
FW422 FACE WASH DETOL 66.00 10
BS145 BATH SOAP DOVE 38.00 20
4
CLIENT
C_ID C_NAME CITY PR_ID
01 DREAM MART COCHIN BS101
02 SHOPRIX DELHI TB310
03 BIG BAZAR DELHI SP235
04 LIVE LIFE CHENNAI FW422
Write SQL Queries for the following:
i) Display the details of those clients whose city is DELHI
ii) Increase the Price of all Bath soap by 10
iii) Display the details of Products having the highest price
iv) Display the product name, price, client name and city with their
corresponding matching product Id.
32 Gupta is writing a program to create a csv file “employee.csv” which will
contain user name and password for department entries. He has written the
following code . As a programmer, help him to successfully execute the given
task.
import ---------------- #statement 1
def add_emp(username,password):
4
f=open(‘employee.csv’, ’----------‘) # statement 2
content=csv.writer(f)
content.writerow([username,password])
f.close()
def read_emp( ):
with open (‘employee.csv’,’r’) as file:
6
content_reader=csv.-------------------(file) # statement 3
for row in content_reader:
print(row[0],row[1])
file.close( )
add_emp(‘mohan’,’emp123#’)
add_emp(‘ravi’,’emp456#’)
read_emp() #statement 4
i) Name the module he should import in statement 1
ii) In which mode , Gupta should open the file to add record in to the
file ? (statement 2)
iii) Fill in the blank in statement 3 to read the record from a csv file
iv) What output will he obtain while executing statement 4 ?
SECTION E
33 Oxford college, in Delhi is starting up the network between its different wings.
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL
as shown below:
7
34 i) What is Pickling or Serialization?
ii) A binary file “salary.DAT” has structure [employee id, employee
name, salary]. Write a function countrec() in Python that would read
contents of the file “salary.DAT” and display the details of those
employee whose salary is above 20000.
OR 2+3=5
i) What is the difference between ‘r’ and ‘rb’ mode in Python file ?
ii) A binary file “STUDENT.DAT” has structure [admission_number,
Name, Percentage]. Write a function countrec() in Python that would
read contents of the file “STUDENT.DAT” and display the details of
those students whose percentage is above 90. Also display number
of students scoring above 90%
35 i) What do you mean by a Primary key in RDBMS ?
ii) Complete the following database connectivity program by writing
the missing statements and performing the given query
import ------------------- as mysql # statement 1
con=mysql. ---------(host=’localhost’,user=’root’,passwd=’123’ ,
database=’student’) # statement 2
cursor=con.cursor( )
cursor.execute(--------------------------------) # statement 3
data=cursor. ----------------------------------- # statement 4
for rec in data:
print(rec)
con.close( )
a) Complete the statement 1 by writing the name of package need to be
imported for database connectivity .
b) Complete the statement 2 by writing the name of method require to
create connection between Python and mysql.
c) Complete the statement 3 by writing the query to display those
students record whose mark is between 50 and 90 from table 1+4=5
“student”
d) Complete the statement 4 to retrieve all records from the result set.
OR
i) What is the difference between UNIQUE and PRIMARY KEY
constraints ?
ii) Maya has created a table named BOOK in MYSQL database,
LIBRARY
BNO(Book number )- integer
B_name(Name of the book) - string
Price (Price of one book) –integer
************************************
8
PB23CS01
MARKING SCHEME
Q.NO QUESTION MARKS
SECTION - A
1 Which of the following is a keyword in Python ?
a) true b) For c) pre-board d) False 1
print(20//3*2+(35//7.0))
1
a) 17.0 b) 17 c) 8.5 d) 8
1
a) 20 b) (20,) c) (10,10) d) Error
8 Fill in the blanks :
The SQL keyword ---------------- is used in SQL expression to select records
1
based on patterns
LIKE
9 What possible outcome will be produced when the following code is executed ?
import random
value=random.randint(0,3)
fruit=["APPLE","ORANGE","MANGO","GRAPE"]
for i in range(value):
print(fruit[i],end='##')
print()
a) APPLE## 1
b) APPLE#
ORANGE##
c) APPLE## ORANGE##
d) ORANGE##
MANGO##
APPLE##
10 Select the network device from the following ,which connects , networks with
different protocols 1
a) Bridge b)Gateway c)Hub d) Router
11 State whether the following statement is TRUE or FALSE :
The value of the expression 4/3*(2-1) and 4/(3*(2-1)) is the same 1
TRUE
12 In the relational models , cardinality actually refers to --------------
a) Number of tuples b) Number of attributes 1
c) Number of tables d) Number of constraints
13 Data structure STACK is also known as ----------- list
a)First In First Out b) First In Last Out 1
c)Last In First Out d) Last In Last Out
14 Which function is used to write a list of strings in a file ?
1
a) Writeline( ) b) writelines( ) c) write() d) writeall( )
15 Which of the following is NOT a guided communication medium ?
a) Twisted pair cable b) Microwave 1
c)Coaxial cable d) Optical fibre
16 Which of the following function headers is correct ?
a) def fun(a=1,b):
b) def fun(a=1,b,c=2): 1
c) def fun(a=1,b=1,c=2):
d) def fun(a=1,b=1,c=2,d):
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
2
(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): In SQL, the aggregate function avg() calculates the average
value on a set of values and produces a single result.
Reason ( R): The aggregate functions are used to perform some fundamental
1
arithmetic tasks such as min(), max(), sum() etc
(b) Both A and R are true and R is not the correct explanation for A .
18 Assertion(A): Python overwrites an existing file or creates a non-
existing file when we open a file with ‘w’ mode.
Reason(R): a+ mode is used only for writing operations
1
(c) A is True but R is False
SECTION - B
19 i) Expand the following :
a) SMTP : Simple Mail Transfer Protocol
b) VoIP : Voice Over Internet Protocol
ii) Give one disadvantage of Star topology
Star topology has a single point of failure. If the central hub or switch fails,
the entire network will be down. This can be a major problem for networks
that require high availability. Or any other dis advantage.
OR
i) What is a web browser ?
A software application used to access information on the World Wide Web is 1+1=2
called a Web Browser. When a user requests some information, the web browser
fetches the data from a web server and then displays the webpage on the user's
screen.
ii) Define the term MAC Address
20 Rewrite the following code in Python after removing all syntax error(s) and
underline each correction done in the code .
num=30
for k in range(0,num): ½ mark
if k%4==0 : each
print(k*4)
else:
print(k+3)
21 Write a function letter_count( lst) that takes a list of string and returns a
dictionary where the keys are the letters from lst and the values are the number
2
of times that letter appears in the lst.
For example: if the passed list is :
3
Lst=list(“apple”)
Then it should return a dictionary as {‘a’:1,’p’:2,’l’:1,’e’:1}
OR
Write a function max_length( ) ,that takes a list of string as argument and
display the longest string from the list.
Correct Program : 2 Marks
lst=[2,4,6,8,10]
for i in range(1,5):
lst[i-1]=lst[i] 2
for i in range(0,5):
print(lst[i],end=' ')
output:
4 6 8 10 10
23 Consider the following list of elements and write Python statement to print the
output of each questions.
elements=['apple',200,300,'red','blue','grapes']
i) print(elements[3:5])
['red', 'blue']
ii) print(elements[::-1])
OR
Consider the following list exam and write Python statement for the following
questions:
i) To insert subject “maths” as last element
exam.append(‘maths’)
ii) To display the list in reverse alphabetical order
exam.sort(reverse=True)
24 Satheesh has created a database “school” and table “student”. Now he wants to
view all the databases present in his laptop. Help him to write SQL command
for that , also to view the structure of the table he created.
SHOW DATABASES
2
DESCRIBE/DESC student
OR
Meera got confused with DDL and DML commands. Help her to select only
DML command from the given list of command.
4
UPDATE , DROP TABLE, SELECT , CREATE TABLE , INSERT INTO,
DELETE , USE
def calc(p,q=3):
ans=1
for x in range(q):
ans=ans*p
return ans
power=calc(3) 2
print(power,'9')
power=calc(3,2)
print(power,'27')
OUTPUT:
27 9
9 27
SECTION C
26 Predict the output of the Python code given below:
def calculate(str):
text=''
x=range(len(str)-1)
for i in x:
if str[i].isupper():
text+=str[i]
elif str[i].islower():
text+=str[i+1]
3
else:
text+='@'
return text
start='Pre-board Exam'
final=calculate(start)
print(final)
OUTPUT:
Pe-@oard @Eam
5
27 Consider the following table DOCTOR given below and write the out put of the
SQL Queries that follows :
28 Write a function in Python to count the number of lines in a text fie ‘EXAM.txt’
which start with an alphabet ‘T’ .
OR
Write a function in Python that count the number of “can” words present in a
text file “DETAILS.txt” .
def count_word():
count=0
6
f=open("textfiles.txt","r")
contents=f.read()
word=contents.split()
for i in word:
if i==’can’:
count+=1
print("Number of words in the File is :",count )
f.close()
count_word()
Based on the above table , Write SQL command for the following :
i) To show all information about the teacher of maths department
SELECT * FROM TEACHER WHERE DEPT=’MATHS’;
ii) To list name and department whose name starts with letter ‘M’
SELECT NAME,DEPT FROM TEACHER WHERE NAME LIKE ‘M%’;
iii) To display all details of female teacher whose salary in between
35000 and 50000
SELECT * FROM TEACHER WHERE SEX=’F’ AND SALARY BETWEEN
35000 AND 50000 ;
30 Thushar received a message(string) that has upper case and lower case 1 mark
alphabet.He want to extract all the upper case letters separately .Help him to do for push
his task by performing the following user defined function in Python: (), 1 mark
7
a) Push the upper case alphabets in the string into a STACK for pop()
b) Pop and display the content of the stack. and 1
For example: mark for
If the message is “All the Best for your Pre-board Examination” displaying
The output should be: E P B A
Ans:
def push(s,ch):
s.append(ch)
def pop(s):
if s!=[]:
return s.pop()
else:
return None
string=“All the Best for your Pre-board Examination”
st=[]
for ch in string:
if ch.isupper():
push(st,ch)
while True:
item=pop(st)
if item!=None:
print(item,end= ‘ ‘)
else:
break
SECTION D
31 Consider the table PRODUCT and CLIENT given below:
PRODUCT
C_ID C_NAME CITY PR_ID
01 DREAM MART COCHIN BS101
02 SHOPRIX DELHI TB310
03 BIG BAZAR DELHI SP235
04 LIVE LIFE CHENNAI FW422
8
Write SQL Queries for the following :
i) Display the details of those clients whose city is DELHI
SELECT * FROM CLIENT WHERE CITY=’DELHI’;
ii) Increase the Price of all Bath soap by 10
UPDATE PRODUCT SET PRICE=PRICE+10 WHERE PR_NAME=’BATH
SOAP’;
iii) Display the details of Products having the highest price
SELECT * FROM PRODUCT WHERE PRICE=(SELECT MAX(PRICE)
FROM PRODUCT) ;
iv) Display the product name , price, client name and city with their
corresponding matching product Id .
SELECT PR_NAME , PRICE ,C_ID, CITY FROM PRODUCT , CLIENT
WHERE PRODUCT.PR_ID=CLIENT.PR_ID ;
def read_emp( ):
with open (‘employee.csv’,’r’) as file:
content_reader=csv.-------------------(file) # statement 3
for row in content_reader:
print(row[0],row[1]) 4
file.close( )
add_emp(‘mohan’,’emp123#’)
add_emp(‘ravi’,’emp456#’)
read_emp() #statement 4
9
SECTION E
33 Oxford college, in Delhi is starting up the network between its different wings.
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL
as shown below:
SENIOR 130
1 mark
JUNIOR 80 each
ADMIN 160
HOSTEL 50
ADMIN
SENIOR
JUNIOR HOSTEL
ii) Suggest the most suitable place (i.e., building) to house the server of
this college , provide a suitable reason.
10
iii) Is there a requirement of a repeater in the given cable layout? Why/
Why not?
v) The organisation also has inquiry office in another city about 50-60
km away in hilly region. Suggest the suitable transmission media to
interconnect to college and inquiry office out of the following :
a. Fiber optic cable
b. Microwave
c. Radiowave
Radio wave
34 i) What is Pickling or Serialization?
The process of converting Python object hierarchy into byte stream so that it can
be written into a file.
ii) A binary file “salary.DAT” has structure [employee id, employee
name, salary]. Write a function countrec() in Python that would read
contents of the file “salary.DAT” and display the details of those
employee whose salary is above 20000.
def countrec():
num=0
fobj=open(“salary.dat”,’rb’)
try:
while True:
rec=pickle.load(fobj)
if rec[2]> 20000:
print(rec[0],rec[1],rec[2])
2+3=5
except:
fobj.close()
OR
i) What is the difference between ‘r’ and ‘rb’ mode in Python file ?
r is used to read text files and rb is used to read binary files
ii) A binary file “STUDENT.DAT” has structure [admission_number,
Name, Percentage]. Write a function countrec() in Python that would
read contents of the file “STUDENT.DAT” and display the details of
those students whose percentage is above 90. Also display number of
students scoring above 90%
import pickle
def countrec():
fobj=open(‘student.dat’,’rb’)
num=0
try:
11
while True:
rec=pickle.load(fobj)
if rec[2]>90:
num=num+1
print(re[0],rec[1],rec[2])
except:
fobj.close()
return num
35
i) What do you mean by a Primary key in RDBMS ?
In the relational model of databases, a primary key is a specific choice of a
minimal set of attributes that uniquely specify a tuple in a relation.
ii) Complete the following database connectivity program by writing
the missing statements and performing the given query
import ------------------- as mysql # statement 1
con=mysql. ---------(host=’localhost’,user=’root’,passwd=’123’ ,
database=’student’) # statement 2
cursor=con.cursor( )
cursor.execute(--------------------------------) # statement 3
data=cursor. ----------------------------------- # statement 4
for rec in data:
print(rec)
con.close( )
i) Complete the statement 1 by writing the name of package
need to be imported for database connectivity .
mysql.connector
ii) Complete the statement 2 by writing the name of method
require to create connection between Python and mysql. 1+4=5
connect()
iii) Complete the statement 3 by writing the query to display
those students record whose mark is between 50 and 90
from table “student”
select * from student where mark between 50 and 90
iv) Complete the statement 4 to retrieve all records from the
result set.
cursor.fetchall()
OR
12
ii) Maya has created a table named BOOKt in MYSQL database,
LIBRARY
MySQL:
Username - root
Password - writer
Host – localhost
13
KENDRIYA VIDYALAYA SANGATHAN, JAIPUR REGION
I-Pre Board Examination 2023-24
Class-12 Subject: Computer Science (083)
Answer Key
SECTION-A
QN. Answer of Question
1. False 1
2. False 1
3. True#False 1
4. False 1
5. (b)Python. is amazing. 1
6. (c) w+ 1
7. (a) foreign key 1
8. (d) UPDATE 1
9. (b) Statement 4 1
10 (b) global p 1
.
11 (a) split() 1
.
12 (a) mango*banana*grapes 1
13 (b) SMTP 1
14 Ans. (a) 16 1
15 (d) flush() 1
16 (a) cursor.rowcount 1
17 Ans. (c) A is True but R is False 1
18 Ans: (a) Both A and R are true and R is the correct explanation for A 1
SECTION-B
19. Num=int(input("Number greater than 10 :")) 2
sum=0
for i in range(10,Num,3):
Sum+=1
if i%2==0:
print(i*2)
else:
__print(i*3)
print(Sum)
20. 1 mark for any correct advantage and disadvantage each 2
OR
Hyper Text Markup Language. Yes it has pre defined tags.
21. (a) Ans: riya riya 1
(b) dict_keys(['empname', 'address', 'salary'])
1
22. Ans. GROUP BY clause is used to get the summary data based on one or more 2
groups. The groups can be formed on one or more columns. For example, the
GROUP BY query will be used to count the number of employees in each
department, or to get the department wise total salaries.
SELECT COUNT(ENAME), SUM(SALARY), DEPT
FROM EMPLOYEES
GROUP BY DEPT;
23. (i) Post office Protocol 3 2
(ii) Voice over Internet Protocol
(b) Ans: Registered Jack-45 is used as connector to connect ethernet cable
to ethernet Port in the CPU
24. Ans: 2
20000 # 100.0
100.0 $ 200
2000 # 200.0
100.0 $ 200.0
1000.0 # 100.0
100.0 $ 200.0
OR
Ans:
(‘Python’)
6
3
25. Ans. Where” clause is used to filter the records from a table 2
that is based on a specified condition, then the “Having” clause
is used to filter the record from the groups based on the
specified condition. OR
b)
(ii) YASHRAJ
UMESH
27. Ans: 3
def beginA():
f=open(‘Notebook.TXT’)
l=f.readlines()
for i in l:
if i[0]==’A’ or i[0]= =’a’:
#or if i[0] in [“A”,”a’]
print(i)
f.close()
OR
fr=open(“PYTHON.TXT”)
fw=open(“PYTHON1.TXT”, ‘w’)
d=fr.read()
for i in d:
if not i.isdigit():
fw.write(i)
fr.close()
fw.close()
½ marks each for correct piece of code
28. Ans. (a) 3
i) Give 1 mark each correct output
SPORTS MIN(PAY)
Karate 1000
Squash 2000
Basketball 1500
Swimming 750
ii) Give 1 mark each correct output
MAX(DATEOFAPP), MIN(DATEOFAPP)
24/02/1998 27/03/1996
def Pop_Element():
global status
m,f=0,0
if status!=[]:
r=status.pop()
if r== ‘F’:
f+=1
else:
m+=1
else:
print(“Female :”,f)
print(“Male :”,m)
print("Done")
OR
def Push(EventDetails):
BigEvents=[]
count=0
for i in EventDetails:
if EventDetails[i]>200:
BigEvents.append(i)
count+=1
print(“The count of elements in the stack is”,count)
SECTION-D
31. Ans. (i) HR because it has maximum number of computers 5*1
(ii) Star topology with HR at centre (any appropriate block diagram)
(iii) Switch need to be installed in each of the block repeater where distance is
greater than 100m
(iv) VoIP
(v) WAN
32. Ans. (a) 2+3
10 # 5
10 # 10
20 # 10
20 # 20
Ans: (b)
Statement 1:
con.cursor()
Statement 2:
mycursor.execute(query)
Statement 3:
con.commit()
OR
OR
Ans: Difference between binary file and csv file: (Any one difference may be
given) Binary file:
Binary csv
Extension is .dat Extension is .csv
Not human readable Human readable
Stores data in the form of 0s and 1s Stores data like a text file
CSV file
Program:
import csv
def add():
fout=open("empdata.csv","a",newline='\n')
wr=csv.writer(fout)
fid=int(input("Enter Emp Id :: "))
fname=input("Enter Emp name :: ")
fprice=int(input("Enter psalary :: "))
FD=[eid,ename,salary]
wr.writerow(FD)
fout.close()
def search():
fin=open("furdata.csv","r",newline='\n')
data=csv.reader(fin)
found=False
print("The Details are")
for i in data:
if int(i[2])>10000:
found=True
print(i[0],i[1],i[2])
if found==False:
print("Record not found")
fin.close()
add()
print("Now displaying")
search()
SECTION-E
34. Ans. (i) ItemNo 1+1
(ii) Cardinality=3 and Degree=9 +2
(iii)
a) Insert into items values (2024, ‘point pen’, 20, 11, 350, ‘2022-NOV-15’);
b) Update items
Set rate=rate+(rate*0.02)
Where Item like ‘%c’;
OR
iii) Delete From items where rate>=10;
b) Alter table items Add column (Remarks Varchar(50));
खंड / SECTION-A
सं / Question अंक /
Q. No. Marks
1. State True or False 1
“break keyword skips remaining part of an iteration in a loop and compiler goes to
starting of the loop and executes again”
2. Find the valid keyword from the following? 1
a) Student-Name b) False c) 3rdName d) P_no
3. What will be the output for the following Python statement? 1
X={‘Sunil’:190, ‘Raju’:10, ‘Karambir’:72, ‘Jeevan’:115}
print(‘Jeevan’ in X, 190 in X, sep=”#”)
(a)True#False (b) True#True
(c) False#True (d) False#False
4. Consider the given expression: 1
True and False or not True
Which of the following will be correct output if the given expression is evaluated?
(a) True (b) False
(b) (c) NONE (d) NULL
5. Select the correct output of the code: 1
a = "Python! is amazing!"
a = a.split('!')
b = a[0] + "." + a[1] + "." + a[2]
print (b)
(a) Python!. is amazing!. (b) Python. is amazing.
(c) Python. ! is amazing.! (d) will show error
6. Which of the following mode in file opening statement overwrite the existing 1
content?
(a) a+ (b) r+
(c) w+ (d) None of the above
7. The attribute which have properties to be as referential key is known as. 1
(a) foreign key (b)alternate key
(c) candidate key (d) Both (a) and (c)
8. Which command is used to change some values in existing rows? 1
(a) CHANGE (b) MODIFY
(b) (c) ALTER (d) UPDATE
9. Which of the following statement(s) would give an error after executing the 1
following code?
Q="Humanity is the best quality" # Statement1
print(Q) # Statement2
Q="Indeed.” # Statement3
Q[0]= '#' # Statement4
Q=Q+"It is." # Statement5
(a) Statement 3 (b) Statement 4 (c)Statement 5 (d)Statement 4 and 5
10. p=150 1
def fn(q):
______________ #missing statement
p=p+q
fn(50)
print(p)
Which of the following statements should be given in the blank for #missing
statement if the output produced is 200
(a) global p=150 (b) global p
(c) p=150 (d) global q
11. Which function is used to split a line of string in list of words? 1
(a)split( ) (b) splt( )
(c) split_line( ) (d) all of these
12. What possible output(s) will be obtained when the following code is executed 1
import random
k=random.randint(1,3)
fruits=[‘mango’, ‘banana’, ‘grapes’, ‘water melon’, ‘papaya’]
for j in range(k):
print(j, end=“*”)
(a) mango*banana*grapes (b) banana*grapes
(c) banana*grapes*watermelon (d) mango*grapes*papaya
13. Fill in the blank: 1
is a communication protocol responsible for sending emails.
(a) TCP (b) SMTP (c) PPP (d)HTTP
14. What will be the ouput when following expression be evaluated in Python? 1
print(21.5 // 4 + (8 + 3.0))
(a) 16 (b)14.0 (c) 15 (d) 15.5
15. Which of the following functions other than close() writes the buffer data to file 1
(a) push() (b) write() (c) writeBuffer() (d) flush()
16. To get counting of the returned rows, you may use……………. 1
(a) cursor.rowcount (b) cursor.count
(c) cursor.countrecords() (d) cursor.manyrecords()
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):- If the arguments in function call statement are provided in the format 1
parameter=argument, it is called keyword arguments.
Reasoning (R):- During a function call, the argument list first contain keyword
argument(s) followed by positional argument(s).
18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage with one 1
record on each line and each field is separated by comma.
Reason (R): The format is used to share data between cross platform as text editors are
available on all platforms.
खंड / SECTION-B
19. Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
Num=int(rawinput("Number greater than 10 :"))
sum=0
for i in range(10,Num,3)
sum+=1
if i%2=0:
print(i*2)
else:
print(i*3)
print(sum)
20. Write one advantage and one disadvantage of packet switching 2
OR
Which language is the most suitable language to create web pages?
21. (a)Given is a Python string : 1
X=”Kendriya Vidyalaya sangathan”
Write the output of: print(X[4:9]*2)
(b) Write the output of the python program code given below:
1
hello = {empname: "Ishan", address: ”New Delhi”, salary: 10000}
hello[salary] = 15000
hello[address] = "Delhi"
print(hello.keys())
22. Explain the use of GROUP BY clause in a Relational Database Management 2
System. Give example to support your answer.
23. (a) Write the full forms of the following: 2
(i)POP3 (ii) VoIP
(b) Define RJ-45?
24. Predict the output of the Python code given below: 2
OR
Predict the output of the Python code given below:
a=tuple()
a=a + tuple(‘Python’)
print(a)
print(len(a))
b=(10,20,30)
print(len(b))
25. Differentiate Where and Having clause in SQL with example. 2
OR
Define aggregate function and give example.
खंड / SECTION-C
26. (a) Consider the following tables – Employee and Office: 1+2
Table: Emp
Emp_Id Name Salary
E01 Lakshya 54000
E02 Ravi NULL
E03 Neeraj 32000
E04 Brijesh 42000
Table: dept
Emp_Id Dept DOJ
E01 Computer 05-SEP-2007
E02 Physics 05-JAN-2008
E03 Sports 30-DEC-2000
E04 English 05-SEP-2012
(b) Consider the following tables SCHOOL and ADMIN. Give the output the following SQL
queries:
27. Write a method beginA() in Python to read lines from a text file Notebook.TXT, and 3
display those lines, which are starting with ‘A’.
For example If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The beginA() function should display the output as:
An apple a day keeps the doctor away.
A marked difference will come in our country.
OR
A text file “PYTHON.TXT” contains alphanumeric text. Write a program that reads this
text file and writes to another file “PYTHON1.TXT” entire file except the numbers or
digits in the file.
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations CLUB and 3
STUDENT given below:
Table : CLUB
COACHID CNAME AGE SPORTS DATEOFAPP PAY GENDER
1 KUKREJA 35 KARATE 27/03/1996 1000 M
2 RAVINA 34 KARATE 20/01/1998 1200 F
3 KARAN 34 SQUASH 19/02/1998 2000 M
4 TARUN 33 BASKETBALL 01/01/1998 1500 M
5 ZUBIN 36 SWIMMING 12/01/1998 750 M
6 KATAKI 36 SWIMMING 24/02/1998 800 F
7 ANKITA 39 SQUASH 20/02/1998 2200 F
8 ZAREEN 37 KARATE 22/02/1998 1100 F
9 KUSH 41 SWIMMING 13/01/1998 900 M
10 SHAILYA 37 BASKETBALL 19/02/1998 1700 M
Table : STUDENT
COACHID SNAME STIPEND STREAM MARKS GRADE CLASS
1 KARAN 400.00 MEDICAL 78.5 B 12B
12 VINNET 450.00 COMMERCE 89.2 A 11C
13 VIVEK 300.00 COMMERCE 68.6 C 12C
4 DHRUV 350.00 HUMANITIES 73.1 B 12C
15 MOHIT 500.00 NONMEDICAL 90.6 A 11A
6 ANUJ 400.00 MEDICAL 75.4 B 12B
17 ABHAY 250.00 HUMANITIES 64.4 C 11A
18 PAYAL 450.00 NONMEDICAL 88.5 A 12A
19 DIKSHA 500.00 NONMEDICAL 92.0 A 12A
10 RISHIKA 300.00 COMMERCE 67.5 C 12C
OR
Write a function in Python, Push(EventDetails) where , EventDetails is a dictionary
containing the number of persons attending the events– {EventName :
NumberOfPersons}. The function should push the names of those events in the stack
named ‘BigEvents’ which have number of persons greater than 200. Also display the
count of elements pushed on to the stack.
For example:
If the dictionary contains the following data:
EventDetails ={"Marriage":300, "Graduation Party":1500, "Birthday Party":80,
"Get together" :150}
खंड / SECTION-D
31. Ripunjay is planning to connect its Delhi Campus with its head office at Goregaon. Its 5*1
Delhi Campus is spread across an area of approx. 1 square kilometers consisting of 3
blocks. HR, Acad and Adm. You as a network expert have to suggest answers to the five
queries (i) to (v) raised by them.
Adm Acad
(i) Suggest the most suitable block in the Delhi Campus to host the server. Give a
suitable reason with your suggestion.
(ii) Suggest the cable layout among the various blocks within the Delhi Campus
for connecting the blocks.
(iii) Suggest the placement of the following devices with appropriate reasons:
a. Switch / Hub
b. Repeater
(iv) Suggest a protocol that shall be needed to provide Video Conferencing solution
between Goregaon Office and Delhi campus.
(v) Suggest the type of network to connect Goregaon Office and Delhi campus.
32. (a) Write the output of the code given below: 2+3
a=5
def add(b=2):
global a
a=a+b
print(a,'#',b)
return a
b=add(a)
print(a,'#',b)
b=add(b)
print(a,'#',b)
(b) The code given below inserts the following record in the table Employee:
EmpNo – integer Name – string
Department – string Salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is brick
The table exists in a MYSQL database named organization.
The details (EmpNo, Name, Department and Salary) are to be accepted
from the user.
OR
(a) Predict the output of the code given below:
a="Give me a glass of water!"
n =len(a)
b=” ”
for i in range(0, n):
if a[i] >= 'a' and a[i] <= 'k':
b = b + a[i].upper()
elif (a[i] >= 'l' and a[i] <= 'z'):
b = b + a[i-1]
elif a[i].isupper():
b = b + a[i].lower()
else:
b = b + '#'
print(b)
(a) The code given below reads the following record from the table named items and
displays only those records who have price greater than 100:
ItemNo –integer
Name – string
Price – integer
Table: items
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpener 23 60 8 31-JUN-09
Classic
2003 Balls 22 50 25 01-FEB-10
2002 Gel Pen Premium 21 150 12 24-FEB-10
2006 Gel Pen Classic 21 250 20 11-MAR-09
2001 Eraser Small 22 220 6 19-JAN-09
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as Primary
key.
(ii) If 3 columns are added and 2 rows are deleted from the table , what will be the
new degree and cardinality of the above table?
(iii) Write the statements to:
a. Insert the following record into the table as (2024, Point Pen, 20, 11, 350,
15-NOV-2022).
b. Increase the rate of the items by 2% whose name ends with ‘c’.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of items having rate greater than equal to 10.
b. Add a column REMARKS in the table with datatype as varchar with 50
characters
35. Anamika is a Python programmer. She has written a code and created a binary file
data.dat with sid, sname and marks. The file contains 10 records.
She now has to update a record based on the sid entered by the user and update the
marks. The updated record is then to be written in the file extra.dat. The records which
are not to be updated also have to be written to the file extra.dat. If the sid is not found,
an appropriate message should to be displayed.
As a Python expert, help him to complete the following code based on requirement given
above:
import ……………. #Statement 1
def update_data():
rec={}
fin=open("data.dat","rb")
fout=open("______________________") #Statement 2
found=False
eid=int(input("Enter student id to update their marks :: "))
while True:
try:
rec= #Statement 3
if rec["student id"]==sid:
found=True
rec["marks"]=int(input("Enter new marks:: "))
pickle. #Statement 4
except:
break
if found==True:
print("The marks of student id ",sid," has been updated.")
else:
print("No student with such id is not found")
fin.close()
fout.close()
(i) Which module should be imported in the program? (Statement1)
(ii) Write the correct statement required to open a temporary file named
extra.dat. (Statement 2)
(iii) Which statement should Anamika fill in Statement 3 to read the data from the
binary file, data.dat and in Statement 4 towrite the updated data in the file,
extra.dat?
KENDRIYA VIDYALAYA SANGATHAN, JAIPUR REGION
PreBoard-I Examination 2023-24
Class-XII
Subject: Computer Science (083)
Answer Key
SECTION-A
QN. Answer of Question
1. Ans. False 1
2. Ans. (c) alter 1
3. Ans: (d) dict_student.update(dict_marks) 1
4. Ans. (b) True 1
5. Ans. (b) DELETE Command 1
6. Ans: (c) HomePage 1
7. Ans. (c) None 1
8. Ans. (a) Year . 0. at All the best 1
9. Ans. (b) Statement 4 1
10. Ans. (c) 512 1
11. Ans: (d) PAN 1
12. Ans. (b) W* 1
B*
13. Ans. (a) Pickling 1
14. Ans. (b) DISTNICT 1
15. Ans. Topology 1
16. Ans. (a) Mycur.fetch() 1
17. Ans. (c) A is True but R is False 1
18. Ans. (c) A is True but R is False 1
SECTION-B
19. (i) (a) IP-Internet Protocol 2
(b) URL- Uniform Resource Locator (1/2 mark for each)
(ii)VoIP is used to transfer audio (voice) and video over internet(1 mark)
OR
(i) Advantage: The network remains operational even if one of the nodes
stopsworking. (1 mark for any ONE advantage)
(ii)
Hub Switch
Hub is a passive Device Switch is an active device
Hub broadcasts messages to all Switch sends the messages to
nodes intended node.
Or any other valid difference between the two.
(1 mark for ANY ONE difference)
20. def reverse(num): 1+1
rev = 0 =2
while num > 0:
rem == num %10
rev = rev*10 + rem
num = num//10
return rev
print(reverse(1234))
(½ Mark for each correction up to any 4 corrections)
1|Page
21. 1+1=
2
OR
def Count_How_Many(Data, item):
count=0
for n in Data:
if(n==item):
count+=1
print(item, " found ", count, "times")
d=[101,102,107,105,102,103,104,102]
i=102
Count_How_Many(d,i)
or any other correct logic
22. ['H', 'A', 'P', 'P', 'Y'] ['B', 'I', 'R', 'T', 'H', 'D', 'A', 'Y'] 2
23. (i) str="PYTHON@LANGUAGE" 2
print(str[2: : ])
(ii) d=dict( )
OR
(i) s=”LANGUAGE"
l=list(s)
(ii) t=tuple( )
24. COUNT(*) returns the count of all rows in the table, whereas COUNT 2
(COLUMN_NAME) is used with Column_Name passed as argument and
counts the number of non-NULL values in a column that is given as
argument. Here discount column is having 4 rows with NULLvalues.
OR
Use KVS; (1/2 mark)
Show Tables; (1/2 mark)
Desc EMPLOYEE;
(1/2 MARK)
Select * from EMPLOYEE; (1/2 MARK)
3|Page
30. data = [1,2,3,4,5,6,7,8] 3
stack = []
def push(stack, data):
for x in data:
if x % 2 == 0:
stack.append(x)
def pop(stack):
if len(stack)==0:
return "stack empty"
else:
return stack.pop()
push(stack, data)
print(pop(stack))
(½ mark should be deducted for all incorrect syntax. Full marks to beawarded
for any other logic that produces the correct result.)
SECTION-D
31. i)SELECT SUM (PERIODS), SUBJECT FROM SCHOOL GROUP BY SUBJECT ; 1*4
ii) SELECT MIN(EXPERIENCE), MAX(CODE) FROM SCHOOL; =4
iii)SELECT TEACHERNAME, GENDER FROM SCHOOL, ADMIN WHERE
DESIGNATION = ‘COORDINATOR’ AND SCHOOL.CODE=ADMIN.CODE;
iv)SELECT COUNT(DISTINCT SUBJECT) FROM SCHOOL;
(1 mark for each correct query)
32. import csv 2+2=
def Add_New(): 4
fout=open("playerdata.csv ","a",newline='\n')
wr=csv.writer(fout)
P_id=int(input("Enter Player Id :: "))
P_name=input("Enter Player name :: ")
P_runs=int(input("Enter price :: "))
playerlist=[P-id,P_name,P_runs]
wr.writerow(playerlist)
fout.close()
def Display_Record():
fin=open("playerdata.csv ","r")
data=csv.reader(fin)
found=False
print("The Player Records are: ")
for Rec in data:
if int(rec[2])>5000:
found=True
print(rec[0],rec[1],rec[2])
if found==False:
print("Such Record not found")
Add_New():
Display_Record():
(½ mark for importing csv module)
(1 ½marks each for correct definition of Add_New() and
Display_Record ())
(½ mark for function call statements )
4|Page
SECTION-E
33. i) ADM Block 1*5=
Justification- It has maximum number of computers. Reduce traffic. 5
ii) wired medium is ethernet cables. Following bus (cable cost efficient) or star
with ADM as centre (network traffic efficient)
DEVELOPMENT HUMANRESOURCE
LOGISTICS ADM
iii) (a) Switches in all the blocks since the computers need to be connected to
the network.
(b) Repeaters between ADM and HUMANRESOURCE block& ADM and Logistics
block. The reason being the distance is morethan 100m.
iv) Modem should be placed in the Server building
v) Optical Fiber cable connection
34. (i) Full form of CSV is Coma Separated Value. 2+3=
pickle module is used for Binary files and csv module is used for 5
importing csv files. (1+ ½ +½)
ii)import pickle
def Trace_Book():
fopen=open("library.dat ","r")
data=pickle.load(fopen)
found=False
print("The Book Records are: ")
for Rec in data:
if (rec[2])<1000:
found=True
print(rec[0],rec[1],rec[2])
if found==False:
print("Such Record not found")
Trace_Book():
OR
(i) (1 mark for each difference between text file and binary file)
(ii)import pickle
def Get_Stud():
Total = 0
Count_rec = 0
Count_age = 0
with open(“ STUDENT.DAT”, “ rb”) as F:
while True:
try:
R=pickle.load(f)
Count_rec = Count_rec+1
Total = Total+R[2]
if R[2] > 18:
print (R[1],“is of Age :”,R[2])
Count_age + = 1
except:
break
if Count_age = =0 :
print(“There is no student who is greater than 18 year”)
5|Page
Get_Stud()
35. (i)Any one difference: 1+4=
CANDIDATE KEY ALTERNATE KEY 5
All attributes in a relation thathave potential to All the leftover candidate keys
become a Primary key after selecting the primary key
(ii)
import mysql.connector as BD
def Emp_Database():
con=BD.connect(host="localhost", user="root", password="bharat",
database="TOUR")
BDcursor=con.cursor()
print("Travels at Hilly Area and the distance more than 1000 KM.:")
BDcursor.execute("select * from TRAVELS WHERE Geo_Cond =’hilly area"
AND Distance<1000)
TravelRec= BDcursor.fetchall()
for rec in TravelRec:
print(rec)
OR
(i)Any one difference:
PRIMARY KEY UNIQUE KEY
There can be only one primary There can be more than one unique
key in a table keys in a table
The primary key cannot have null Unique can have null values
values
(ii)
import mysql.connector as cnt
def Emp_Database():
con=cnt.connect(host="localhost", user="root", password="tiger",
database="company")
mycursor= con.cursor()
print("Display Employee whose age is more than 55 years:")
mycursor.execute("select * from Emp where age>55”)
EmpRec= mycursor.fetchall()
for rec in EmpRec:
print(rec)
6|Page
क ीय िव ालय संगठन, जयपुर संभाग
Kendriya Vidyalaya Sangathan, Jaipur Region
थम ी-बोड परी ा 2023-24
First Pre-Board Exam 2023-24
क ा/Class: XII िवषय/Subject : Computer Science (083)
समय : 3 घंटे पूणाक/Max Marks: 70
खंड / SECTION-A
सं / Question अंक /
Q. No. Marks
1. State True or False 1
“ continue keyword is not a jump statement in a loop.”
2. Fill in the blank: 1
command is used to remove a column from a table in SQL.
(a)update (b)remove (c) alter (d)drop
3. Given the following dictionaries 1
dict_stud = {"rno" : "53", "name" : ‘Rajveer Singh’}
dict_mark = {"Accts" : 87, "English" : 65}
Which statement will merge the contents of both dictionaries in dict_stud?
(a) dict_stud + dict_mark (b) dict_stud.add(dict_mark)
(c) dict_stud.merge(dict_mark) (d) dict_stud.update(dict_mark)
4. 1
print(True or not True and False)
Choose one option from the following that will be the correct output after executing
the above python expression.
a) False b) True c) or d) not
5. Which of the following commands will delete the rows of table? 1
(a) DROP command (b) DELETE Command
(c) REMOVE Command (d) ALTER Command
6. Fill in the blank: 1
______is the first page that normally view at a website.
(a) First Page (b) Master Page (c) Home Page (d) Login Page
7. When a Python function does not have return statement then what it returns? 1
(a) int (b) float (c) None (d)Give Error
8. Select the correct output of the code: 1
>>> a= "Year 2022 at All the best"
>>> a = a.split('2')
>>> a = a[0] + ". " + a[1] + ". " + a[3]
1|Page
>>> print (a)
(a) Year . 0. at All the best (b) Year 0. at All the best
(c) Year . 022. at All the best (d) Year . 0. at all the best
9. Which of the following statement(s) would give an error after executing the 1
following code?
S="Welcome to class XII" # Statement 1
print(S) #Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5
2|Page
Reasoning (R): All variables declared outside are not visible inside a function
till they are redeclared with global keyword.
18. Assertion (A): A binary file in python is used to store collection objects like lists and 1
dictionaries that can be later retrieved in their original form using pickle module.
Reasoning (R): A binary files are just like normal text files and can be read
using a text editor like notepad.
खंड / SECTION-B
19. (i) Write the full forms of the following: (a) IP (b) URL 1+1=
(ii) What is the use of VoIP? 2
OR
(i) Mention one advantage of Star Topology.
(ii) Mention one difference between a Hub and switch in networking.
20. Observe the following Python code very carefully and rewrite it after removing all 2
syntactical errors with each correction underlined.
Define reverse(num):
rev = 0
While num > 0:
rem == num %10
rev = rev*10 + rem
num = num//10
return rev
print(reverse(1234))
21. Write a function INDEX_LIST(L), where L is the list of elements passed as argument to 2
the function. The function returns another list named ‘indexList’ that stores the
indices of all Non-Zero Elements of L.
For example:
If L contains: [2, 0, 5, 0, 1, 0, 0]
3|Page
(i) s=”LANGUAGE"
To convert the above string into list.
(ii) To initialize an empty tuple named as t.
24. A MySQL table, sales have 10 rows with many columns, one column name is 2
DISCOUNT. Following queries were executed on sales table.
SELECT COUNT(*) FROM sales;
COUNT(*)
10
SELECT COUNT(DISCOUNT) FROM sales;
COUNT( DISCOUNT )
6
Write a statement to explain as to why there is a difference in result of both queries.
OR
Write commands to open database ‘KVS’ and show all tables in this database. And
display design/schema/structure of the table EMPLOYEE which is inside this
database. And display all the records of table EMPLOYEE.
25. Predict the output of the Python code given below: 2
data = [20,19,19,17,20,19,17,20]
d = {}
for x in data:
if x in d:
d[x]=d[x]+1
else:
d[x]=1
print(d)
खंड / SECTION-C
26. Write the output of the code given below: 3
def change(Line):
alpha=str()
digi=str()
for ch in Line:
if(ch.isalpha()):
if(ch.islower()):
alpha=alpha+ch.upper()
elif(ch.isupper()):
alpha=alpha+ch.lower()
elif(ch.isdigit()):
alpha=alpha+ch+ch
print(Line)
print(alpha)
change("Vande 0 Bharat 9 Train 1")
27. Write the output of queries (i) to (iii) based on the table Sportsclub given below: 1*3=
Table: Sportsclub 3
playerid pname sports country rating salary
10001 PELE SOCCER BRAZIL A 50000
10002 FEDERER TENNIS SWEDEN A 20000
10003 VIRAT CRICKET INDIA A 15000
10004 SANIA TENNIS INDIA B 5000
10005 NEERAJ ATHLETICS INDIA A 12000
10006 BOLT ATHLETICS JAMAICA A 8000
10007 PAUL SNOOKER USA B 10000
(i) SELECT DISTINCT sports FROM Sportsclub;
(ii) SELECT sports, MAX(salary) FROM Sportsclub GROUP BY sports
4|Page
HAVING sports<>'SNOOKER';
(iii) SELECT pname, sports, salary FROM Sportsclub WHERE
country='INDIA' ORDER BY salary DESC;
28. A pre-existing text file data.txt has some words written in it. Write a python function 3
displaywords( ) that will print all the words that are having length greater than 3.
If the contents of file is :
A man always wants to strive higher in his life
He wants to be perfect.
The output should be: always wants strive higher life wants perfect.
OR
Write a method count_lines( ) in Python to read lines from text file ‘student.txt’ and
display the total number of line in file and lines which are ending with ‘y’ alphabet and
not ending with ‘y’ separately.
29. Monika is a senior clerk in a MNC. She created a table ‘Salary’ with a set of records to 1*3=
keep ready for tax calculation. After creation of the table, she has entered data of 5 3
employees in the table.
30. A list of numbers is used to populate the contents of a stack using a function push(stack, 3
data) where stack is an empty list and data is the list of numbers.The function should
push all the numbers that are even to the stack.
Also write the function pop(stack) that removes and returns the top element of the
stack on its each call.
5|Page
खंड / SECTION-D
31. Write the SQL queries (i) to (iv) based on the relations SCHOOL and ADMIN given below: 1*4=4
DEVELOPMENT HUMANRESOURCE
PMENT
KVS
LOGISTICS ADM
RO
6|Page
Block DEVELOPMENT to Block LOGISTICS-- 80 m
Block HUMANRESOURCE to Block ADM-- 110 m
Block ADM to Block LOGISTICS 140 m
a) Suggest the most suitable block to host the server. Justify your answer.
b) Suggest the wired medium and Draw the cable layout (Block to Block) to
economically connect various blocks.
c)Suggest the placement of the following devices with justification:
(i) Hub/Switch (ii)Repeater
d)Suggest the device that should be placed in the Server building so that they can
connect to Internet Service Provider to avail Internet Services.
e) Suggest the high-speed wired communication medium between Bangalore Campus
and Mysore campus to establish a data network.
34 (i) What is CSV means? Which packages/modules are imported for using Binary Files 2+3= 5
. and CSV files in Python?
(ii) Abhay have a binary file called library.dat containing book information- B_id, B_name
and B_price of each book.
[[B_id, B_name, B_price],[B_id, B_name, B_price],…]
Write the user defined function Trace_Book() to show the records of books having the
price less than 1000. In case there is no book having price <1000 the function displays
message “Such Record not found”.
OR
(i) Write any two difference between text file and binary file.
(ii)Mayur is a student, who have a binary file called STUDENT.DAT containing employee
information- sid, name and age of each student.
[sid, name , age]
Write the user defined function Get_Stud() to display the name and age of those student
who have a age greater than 18 year. In case there is no student having age >18 the
function displays message “There is no student who is greater than 18 year”.
35 (i) What is the difference between a Candidate Key and an Alternate Key. 1+4=5
.
(ii) Virat has created a table named TRAVELS in MySQL:
Tour_ID – string
Destination – String
Geo_Cond– String
Distance – integer (In KM)
Virat wants to display All Records of TRAVELS relation whose Geographical condition
7|Page
is hilly area and distance less than 1000 KM. Help Virat to write program in python.
OR
(i) Write one point of difference between PRIMARY KEY and UNIQUE KEY in SQL.
----------------*------------*------------------
8|Page
Class XII
Marking Scheme
SECTION A
1 True 1 mark for 1
correct
answer
[1]
9 Option b 1 mark for 1
correct
Statement 4 answer
[2]
18 Option a 1 mark for 1
correct
Both A and R are true but R is the correct explanation for A answer
SECTION B
19 (i) ½ mark for 1+1=2
each correct
SMTP – Simple Mail Transfer Protocol expansion
(ii)
1 mark for
Active hubs amplify the incoming electric signal, whereas passive hubs any one
do not amplify the electric signal. (Any other valid difference may be
correct
considered)
difference
OR
(i) A network protocol is an established set of rules that determine 1 mark for
how data is transmitted between different devices in the same correct
network.
definition
(ii) Hub is an electronic device that connects several nodes to form
a network and redirect the received information to all the nodes 1 mark for
in a broadcast mode. Whereas Switch is an intelligent device
any one
that connects several nodes to form a network and redirect the
received information only to the intended node(s). correct
difference
(Any other valid difference may be considered)
[3]
21 ½ mark for 2
correct
SUBJECT={1:"Hindi",2:"Physics",3:"Chemistry",4:"CS",5:"MATH"}
function
def countMy (SUBJECT): header
for S in SUBJECT.values():
½ mark for
if len(S)>5:
correct loop
print(S.upper())
½ mark for
countMy()
correct if
statement
½ mark for
displaying
the output
OR
½ mark for
correct
def lenLines (STRING):
function
t=()
header
L=STRING.split()
for line in L: ½ mark for
using split()
length=len(line)
½ mark for
t=t+(length,)
adding to
return t
tuple
½ mark for
return
statement
[4]
23 (i) L1.insert(1,100) 1 mark for 1+1=2
each correct
(ii) S1.isdigit() statement
OR
pop() function removes the last value and returns the same.
>>>L.remove (20)
OR
1 mark for
DDL : CREATE, ALTER DROP each correct
DDL & DML
DML: INSERT UPDATE DELETE Categorized
commands
25 ½ mark for 2
-22 # 756 # -9 # 230 #
each correct
number and ½
mark for each
correct #
symbol
SECTION C
26 ['DelhiDelhi', 'JaipurJaipur', 'AgraAgra', 'SuratSurat', 'MumbaiMumbai', ½ mark for 3
'BhopalBhopal'] each correct
output
[5]
27 1*3=3
1 mark for
each
(a) (b) (c) correct
Item Name Dateofstock Type Sum(Price)
White lotus 13/12/2001 Double Bed 80000 output.
Comfort Zone 22/02/2002 Baby Cot 30500
Wood Comfort 20/02/2003 Office Table 43000
Sofa 57500
Dining Table 11500
28 def SHOWWORD () : (½ Mark for 3
c=0 opening the file)
file=open(‘STORY.TXT,'r') (½ Mark for
line = file.read() reading line
and/or splitting)
word = line.split()
(½ Mark for
for w in word: checking
if len(w)<5: condition)
print( w) (½ Mark for
file.close() printing word)
OR
def count H( ):
f = open (“para.txt” , “r” )
lines =0
L=f. readlines ()
for i in L:
if i [0]== ‘H’:
lines +=1
print (“No. of lines are: “ , lines)
29 (i) 1 mark for 1*3=3
each correct
UPDATE EMP
query
SET Salary=Salary + Salary*0.10
WHERE Allowance IS NOT NULL;
(iii)
DELETE FROM EMP
WHERE Salary>40000;
[6]
30 N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38] 1½ marks for 3
def PUSHEl(S,N):
S.append(N)
each Push
def POPEl(S): and Pop
if S!=[]: operation
return S.pop()
else:
return None
ST=[]
for k in N:
if k%4==0:
PUSHEl(ST,k)
while True:
if ST!=[]:
print(POPEl(ST),end=" ")
else:
break
SECTION D
31 (i) 1 mark for 1*4=4
each correct
3
output
(ii)
1
1
2
(iii)
Dname Pname
PARESH Lal singh
MANISH Arjun
AKASH Narender
KUMAR Mehul
PARESH Naveen
MANISH Amit
(iv)
Manish
[7]
32 ½ mark for 4
import csv accepting
def createcsv(): data
f=open("result.csv","w", newline="")
correctly
w=csv.writer(f)
w.writerow([1,'Anil',40,34,90,""])
½ mark for
w.writerow([2,'Sohan',78,34,90,""])
w.writerow([3,'Kamal',40,45,9,""]) opening and
f.close() closing file
½ mark for
reader object
½ mark for
print heading
½ mark for
printing data
SECTION E
33 (i) M/s Computer Solutions should install its server in finance block as it 1 Mark of 1*5=5
each correct
is having maximum number of computers. answer
(ii) Any suitable layout
(iv) Switch.
(v) LAN
[8]
34 (i) 1 mark for 2+3=5
rb+ Opens a file for both reading and writing in binary format. (+) the file each correct
pointer will be at the beginning of the file.
difference
wb+ Opens a file for both reading and writing in binary format. Overwrites ½ mark for
the existing file If the file exists. If the file does not exist, creates a new
file for reading or writing. correctly
opening and
(ii) def Readfile(): closing files
s=open( “Employee.dat” , “rb+”)
try:
while True:
r=pickle.load(s)
if r[2]>=20000 and r[2]<=30000:
print(r)
except: ½ mark for
print(“end of file”) correct loop
OR ½ mark for
correct split
1 mark for
correctly
(i) reading /
In pickle module, dump () method is used to convert (pickling) writing data
Python objects for writing data in a binary file
½ mark for
Whereas the load () function is used to read data from a binary printing
file or file object.
data
(ii)
import pickle as p
L=[]
with open(‘emp.dat’,’rb’) as f:
L=p.load(f)
for r in L:
if r[2]>5000:
print(“name=”,r[0])
print(“designation=”,r[1])
print(“salary=”,r[2])
[9]
35 (i) A table can only have one primary key, but it can have multiple ½ mark for 1+4=5
candidate key in a database. (any suitable example) correct
definition
OR ½ mark for
correctly
(i)
accepting the
Degree: The total number of attributes which in the relation is called the input
degree of the relation.
Cardinality: Total number of rows present in the Table. 1 ½ mark for
(any suitable example) correctly
displaying
(ii)
data
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="admin",databas
e="SCHOOL")
mycursor=mydb.cursor()
mycursor.execute("alter table emp add (bonus int(3))")
mycursor.execute("desc emp")
for x in mycursor:
print(x)
[10]
क ीय िव ालय संगठन, जयपुर संभाग
Kendriya Vidyalaya Sangathan, Jaipur Region
थम ी-बोड परी ा 2023-24
First Pre-Board Exam 2023-24
क ा/Class: XII िवषय/Subject : Computer Science (083)
समय : 3 घंटे पूणाक/Max Marks: 70
खंड / SECTION-A
सं / Question अंक /
Q. No. Marks
1 State True or False: 1
“Lexical unit is the smallest unit of any programming language”
[1]
5 In MYSQL database, if a table, Emp has degree 10 and cardinality 5, and 1
another table, Dept has degree 5 and cardinality 10, what will be the degree
and cardinality of the Cartesian product of Emp and Dept ?
a. 50,15 b. 15,50
c. 50,50 d. 15,15
6 Ankur wants to transfer songs from his mobile phone to his laptop. He uses 1
Bluetooth Technology to connect two devices. Which type of network will be
formed in this case?
a. PAN b. LAN
c. MAN d. WAN
7 Give the output: 1
dic1={‘r’:’red’,’g’:’green’,’b’:’blue’}
for i in dic1:
print (i, end =’ ’)
a. r g b b. R G B
c. R B G d. red green blue
8 Consider the statements given below and then choose the correct output 1
from the given options:
MN="Bharat @G20"
print(MN[-2:2:-2])
Options:
a. rt@2 b. 2@tr
c. @G20 d. 02G@
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
[2]
10 What possible outputs(s) will be obtained when the following code is 1
executed?
import random
Signal=['Stop','Wait','Go']
for K in range (2,0,-1):
R=random.randrange(K)
print(Signal[R], end='#')
options:
a. Stop#Go#
b. Wait#Stop#
c. Go#Stop#
d. Go#Wait#
x=5
def function1():
global x
y=x+x*2
print(y,end=”,”)
x=7
function1()
print(x)
Output:
a. 21 , 7
b. 15 , 5
c. 21 , 5
d. 15, 7
[3]
13 State whether the following statement is True or False: 1
Exception handling can be done for both user-defined and built-in exceptions.
transmitted between sender and receiver is broken down into smaller pieces.
a.tellg()
b.tell()
c.seek()
d.seekg()
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 1
Assertion(A): Access mode ‘a’ opens a file for appending.
Reasoning(R): The file pointer is at the end of the file if the file exists.
18 1
Assertion(A): A function is block of organized and reusable code that is used to
perform a single, related action.
Reasoning(R): Function provides better modularity for your application and a high
[4]
खंड / SECTION B
OR
(i) Define the term Protocol with respect to networks.
(ii) How is Hub different from Switch?
20 Harsh has written a code to input a number and find a table of any number. His 2
code is having errors. Rewrite the correct code and underline the corrections
made.
def table():
n=int(("Enter number which table U need: ")
for i in (1,11):
print("Table of Enter no=”,i*i)
Table()
[5]
22 Predict the output of the following code: 2
tuple1 = (11,22,33,44,55,66)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%2==0 :
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
23 Write the Python statement for each of the following tasks using BUILT-IN 1+1=
functions/methods only: 2
(i) To insert an element 100 at the Second position, in the list L1.
(ii) To check whether all the characters in the string S1 are digits or not.
OR
How the pop( ) function is different from remove( ) function working with
list in python ? Explain with example.
24 Pooja wrote a query in SQL for student table but she is not getting desired result 2
select * from student where fee = NULL;
Rewrite the above query so that she gets desired result
OR
def Diff(N1,N2):
if N1<N2:
return N1-N2
else:
return N2*N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')
[6]
खंड / SECTION C
27 Write the outputs of the SQL queries (a) to (c) based on the relation Furniture 1*3
=
No Itemname Type Dateofstock Price Discount 3
1 White lotus Double Bed 23/02/2002 30000 25
2 Pink feather Baby Cot 20/01/2002 7000 20
3 Dolphin Baby Cot 19/02/2002 9500 20
4 Decent Office 01/01/2002 25000 30
Table
5 Comfort Double Bed 12/01/2002 25000 25
Zone
6 Donald Baby Cot 24/02/2002 6500 15
7 Royal finish Office 20/02/2002 18000 30
Table
8 Royal tiger Sofa 22/02/2002 31000 30
9 Econo sitting Sofa 13/12/2001 9500 25
10 paradise Dining 19/02/2002 11500 25
Table
11 Wood Double Bed 23/03/2003 25000 25
Comfort
12 Old Fox Sofa 20/02/2003 17000 20
13 Micky Baby Cot 21/02/2003 7500 15
[7]
29 Consider the table Emp given below: 1*3=
3
Table : EMP
Based on the given table, write SQL queries for the following:
(i) Increase the salary by 10% of employees whose allowance is known.
(ii) Display Name and Total Salary (sum of Salary and Allowance) of all
employees. The column heading ‘Total Salary’ should also be
displayed.
(iii) Delete the record of employess who have salary greater than 40000.
30. Mr.Abhishek has created a list of elements. Help him to write a program in 3
python with functions, PushEl (S,element) and PopEl (S) to add a new
element and delete an element from a List of element named ‘S’ considering
them to act as push and pop operations of the Stack data structure . Push the
element into the stack only when the element is divisible by 4.
32 <- Top
24
[8]
खंड / SECTION D
31 Consider the doctor and patient table and write the output of (i) to (iv) 1*4=
4
Doctor
docid Dname Specialization Outdoor
D1 MANISH PHYSICIAN MONDAY
D2 PARESH EYE FRIDAY
D3 KUMAR ENT SATURDAY
D4 AKASH ENT TUESDAY
Patient
Pid Pname did Date_visit
P1 Lal singh D2 2022-04-25
P2 Arjun D1 2022-05-05
P3 Narender D4 2022-03-13
P4 Mehul D3 2022-07-20
P5 Naveen D2 2022-05-18
P6 Amit D1 2022-01-22
Initially student total field is empty string as example data is given below
['1', 'Anil', '40', '34', '90', '']
['2', 'Sohan', '78', '34', '90', '']
['3', 'Kamal', '40', '45', '9', '']
A another file “final.csv” is created which reads records of “result.csv” and copy all
records after calculating total of marks into final.csv. The contents of final.csv
should be
['1', 'Anil', '40', '34', '90', '164']
['2', 'Sohan', '78', '34', '90', '202']
['3', 'Kamal', '40', '45', '9', '94']
(a) Define a function createcsv() that will create the result.csv file with the
sample data given above.
(b) Define a function copycsv() that reads the result.csv and copy the same
data after calculating total field into final.csv file.
[9]
खंड / SECTION E
FINANCE BLOCK
(i) Which will be the most appropriate block, where M/s Computer
Solutions should plan to install their server?
(ii) Draw a block to block cable layout to connect all the buildings in the
most appropriate manner for efficient communication.
(iii) What will be the best possible connectivity out of the following, you will
suggest to connect the new set up of offices in Bengalore with its
London based office.
Satellite Link
Infrared
Ethernet
(iv) Which of the following device will be suggested by you to connect each
computer in each of the buildings?
Switch
Modem
Gateway
(v) Company is planning to connect its offices in Hyderabad which is less
than 1 km. Which type of network will be formed?
[10]
34 2+3=
5
(i) Differentiate between rb+ and wb+ file modes in Python.
(ii) Consider a binary file “employee.dat” containing details such as
(empno, ename, salary). Write a python function to
display details of those employees who are earning between 20000 and
30000 (both values inclusive).
OR
(i) Differentiate between dump and load functions in binary files?
(ii) Write a Python function in Python to search the details of the employees
[name, designation, salary] whose salary is greater than 5000. The
records are stored in the file “emp.dat”. consider each record in the file
emp.dat as a list containing name, designation and salary.
35 (i) How many candidate key and primary key a table can have in a Database? 1+4=
5
(ii) Manish wants to write a program in Python to create the following table
named “EMP” in MYSQL database, ORGANISATION:
Eno (Employee No )- integer , Ename (Employee Name) - string
Edept (Employee Department)-string, Sal (salary)-integer
Note the following to establish connectivity between Python and MySQL:
Username – root , Password – admin , Host - localhost
The values of fields eno, ename, edept and Sal has to be accepted from the
user. Help Manish to write the program in Python to insert record in the above
table..
OR
(i) Differentiate between degree & cardinality key in RDBMS?
(iii) Vihaan wants to write a program in Python to create the following table
named “EMP” in MYSQL database, ORGANISATION:
Eno (Employee No )- integer , Ename (Employee Name) - string
Edept (Employee Department)-string, Sal (salary)-integer
Note the following to establish connectivity between Python and MySQL:
Username – root , Password – admin , Host - localhost
Help Vihaan to write the program in Python to Alter the above table with new
column named Bonus (int).
[11]
(SET 1)
SECTION
A
1. State True or False 1
“Dictionaries in python are mutable.”
Ans:True
2. Which of the following is an invalid identifier 1
a)myname b)p9tv c)def d)_new
Ans:c def
3. Which one of the following is the function to get list of keys from a dictionary 1
dict in python?
a. dict.getkeys()
b. dict.getvalues()
c. dict.keys()
d. None Of These
Ans: c dict.keys()
4. Consider the given expression: 1
True OR NOT False AND True
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
Ans:A True
5. Select the correct output of the code: 1
Str=”I will Succeed”
1
lis=str.split(““)
print(lis[-1])
(a) I
(b) will
(c) Succeed
(d) ”I will Succeed”
ANS:c Succeed
6. Which of the following methods will give the current position of the file 1
pointer?
ANS:b tell()
7. Fill in the blank: 1
ANS: c alter
8. Which of the following commands will delete the contents of the table from 1
MYSQL database?
(a) DELETE
(b) DROPTABLE
(c) REMOVETABLE
(d) ALTERTABLE
ANS:a DELETE
9. Which of the following statement(s) would give an error after 1
executing the following code?
T=(8,9,7,6) # Statement 1
print(T) # Statement2
T=(7,9,7,6) # Statement3
T[1]=8 # Statement4
T=T+(1,2,3) # Statement5
(a) Statement3
(b) Statement4
(c) Statement5
(d) Statement 4 and5
ANS:b statement 4
2
10. Fill in the blank: 1
ANS:b read
12. Which of the following can be used as command to get the structure of a table in 1
mySQL
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
ANS:a DESCRIBE
13. Fill in the blank: 1
Is the protocol used for server to server mail transfer?
ANS:b SMTP
ANS: b 64
3
16. Which function is used to establish connection between python and SQL 1
database?
(a) connection
(b) connect
(c) getconnection
(d) getconnect
ANS:b connect
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):-Functions in a program increases the modularity and readability 1
of the program
Reasoning (R):-Usage of Functions increases the execution speed of the
program
18. Assertion (A): If a file is opened in binary mode its contents are viewed as a 1
sequence of bytes.
Reason (R): A text file also can be opened in binary mode
ANS: b Both A and R are true and R is not the correct explanation for A
SECTION
B
19. Rahul has written a code to input a number and return its reverse. His code is 2
having errors. Rewrite the correct code and underline the corrections made.
def reverse()
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev
ANS:
def reverse():
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev
OR
ANS:MODULATOR DEMODULATOR
2marks for correct explanation.
OR
25. Explain the use of DISTINCT keyword in python with appropriate example 2
ANS:DISTINCT keyword discards duplicate vales
1 mark for explanation and 1 mark for example
OR
SECTION C
b)Write the outputof the queries (i) to (iv) based on the table EMPLOYEE given
below
Empid Empname Salary Deptid
6
E1 Prabhath 12000 D1
E2 Nikhil 14000 D1
E3 Devansh 10000 D2
E4 Debraj 15000 D3
E5 Aron 18000 D1
(iii)
Empname
Aron
Debraj
1/2 marks
(iv)
Sum(Salary)
33000
1/2 marks
27. Write a method COUNTLINES() in python to read lines from text file 3
MYSTORY.TXT and display the count of lines which are starting with letter T
Example:if the file content is as follows:
Trees are the precious
We should protect trees
This way we can serve nature
ANS:
def COUNTLINES():
fp=open("MYSTORY.TXT","r")
7
count=0
lines=fp.readlines()
for line in lines:
if(line[0]=="T"):
count=count+1
print("The number of lines starting with letter T :",count)
OR
Example:
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
BOOK
Book_id Book_name Price Qty Author_id
1001 My first C++ 323 12 204
1002 SQL basics 462 6 202
1003 Thunderbolts 248 10 203
1004 The tears 518 3 204
AUTHOR
Author_id Author_name Country
201 William Hopkins Australia
202 Anita India
203 Anna Roberts USA
204 Brain&Brooke Italy
For example:
If L contains [1,2,3,4,5,6,7,8]
Write the following user defined functions to perform given operations on the
stack named ‘stud_details’:
(i) Push_element() - To Push an object containing nameand
age of students who live in hostel “Ganga” to the stack
(ii) Pop_element() - To Pop the objects from the stack and display
them. Also, display “Stack Empty” when there are no elements in
thestack.
For example:
If the lists of customer detailsare:
[“Barsat”,17,”Ganga”]
[“Ruben”, 16,”Kaveri”]
[“Rupesh”,19,”Yamuna”]
The stack should contain
[“Barsat”,17,”Ganga”]
The output should be:
[“Barsat”,17,”Ganga”]
Stack Empty
ANS:
stud_details=[]
def push_element(lis):
if(lis[2]=="Ganga"):
stud_details.append([lis[0],lis[1]])
def pop_element():
while(len(stud_details)>0):
print(stud_details.pop())
print("Stack Empty")
OR
31
HiTech Training center, a Mumbai based organization is planning to
expand their training institute to Chennai. At Chennai compound,
they are planning to have three different blocks for admin, training
and accounts related activities. As a network consultant you have to
suggest some network related solutions to the organization
Suggest the most suitable block to house the server at Chennai block for 1
ii) best and effective connectivity.
Suggest the type of network for the new training institute and draw 1
iii) the cable layout for the Chennai office
Suggest a hardware/software that would provide the data security 1
iv) for entire network of Chennai region.
Suggest a device that shall be needed to provide wireless 1
v) internet access to all smart phones/laptop users in Chennai office.
Suggest the protocol used for video conferencing between Chennai
11
office and Mumbai office
ANS:
i)Training Block
ii)LAN
iii)FIREWALL
iv)ACCESS POINT
v)H.323 or SIP
32. (a) Write the output of the code given below: 2+3
val=4
def findval(m,n=10):
val=0
val=val+m*n
a=10
b=20
findval(a,b)
print(val,end="-")
findval(a)
print(val,end="-")
ANS:4-4-
(b) The code given below inserts the following record in the table
Employee:
import mysql.connector
from mysql.connector import Error
connection = mysql.connector.connect(host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=_______________________#STATEMENT1
empid=int(input("enter Empid")) 12
name=input("enter name")
salary=float(input("ENTER SALARY"))
result = __________________________#STATEMENT2
___________________________________#STATEMENT3
ANS:
STATEMENT1:connection.cursor()
STATEMENT2:cursor.execute("insert into employee
values(%s,%s,%s)",(empid,name,salary))
STATEMENT3:connection.commit()
OR
(b) The code given below reads the following record from thetable
named Employeeand displays only those records who have Salary
greater than 25000:
import mysql.connector
connection = mysql.connector.connect(host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=________________________#STATEMENT1
_________________________________________#STATEMENT2
13
records = _____________________________#STATEMENT3
for row in records:
print("Empid",row[0],end=" ")
print("name",row[1],end=" ")
print("salary",row[2],end=" ")
print()
ANS:
Statement 1 :connection.cursor()
Statement 2 :cursor.execute("select * from employee where salary>25000")
Statement 3:cursor.fetchall()
33. What is a csv file? 5
Write a Program in Python that defines and calls the following user defined
functions:
def COUNTSTUDENTS():
file=open("student.csv","r")
reader=csv.reader(file)
print("No of students",len(reader))
OR
34. Rahul created following table TRAVEL to store the travel details 1+1+2
ANS:
a)(i)TNO (ii)degree-9 cardinality-6
iii)a.INSERT INTO TRAVEL VALUES(110,’BIMAL’,’28-11-
2022’,200,’VOLVOBUS’,40)
b.UPDATE TRAVEL SET KM=KM+10 WHERE VTYPE=’VOLVO
BUS’
OR (Option for part iii only)
17
18
19
(SET 1)
Computer Science (083)
PRE BOARD EXAMINATION 2023-24
SECTION A
1. State True or False 1
“Dictionaries in python are mutable.”
2. Which of the following is an invalid identifier 1
a)myname b)p9tv c)def d)_new
3. Which one of the following is the function to get list of keys from a dictionary 1
dict in python?
a. dict.getkeys()
b. dict.getvalues()
c. dict.keys()
d. None Of These
(a) True
(b) False
(c) NONE
(d) NULL
1
lis=str.split(“ “)
print(lis[-1])
(a) I
(b) will
(c) Succeed
(d) ”I will Succeed”
6. Which of the following methods will give the current position of the file 1
pointer?
8. Which of the following commands will delete the row of the table from 1
MYSQL database?
(a) DELETE
(b) DROPTABLE
(c) REMOVETABLE
(d) ALTERTABLE
T=(8,9,7,6) # Statement 1
print(T) # Statement2
T=(7,9,7,6) # Statement3
T[1]=8 # Statement4
T=T+(1,2,3) # Statement5
(a) Statement3
(b) Statement4
(c) Statement5
(d) Statement 4 and5
2
(d) Alternate Key
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
13. Fill in the blank: 1
Is the protocol used for server to server mail transfer?
16. Which function is used to establish connection between python and SQL 1
database?
(a) connection
(b) connect
(c) getconnection
(d) getconnect
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
3
(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):-Functions in a program increases the modularity and readability 1
of the program
Reasoning (R):-Usage of Functions increases the execution speed of the
program
18. Assertion (A): If a file is opened in binary mode its contents are viewed as a 1
sequence of bytes.
Reason (R): A text file also can be opened in binary mode
SECTION B
19. Rahul has written a code to input a number and return its reverse. His code is 2
having errors. Rewrite the correct code and underline the corrections made.
def reverse()
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev
OR
4
(b) What is the use of POP3?
OR
25. Explain the use of DISTINCT keyword in python with appropriate example 2
OR
SECTION C
27. Write a method COUNTLINES() in python to read lines from text file 3
MYSTORY.TXT and display the count of lines which are starting with letter T
Example:if the file content is as follows:
Trees are the precious
We should protect trees
This way we can serve nature
OR
Example:
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
6
BOOK
AUTHOR
If L contains [1,2,3,4,5,6,7,8]
Write the following user defined functions to perform given operations on the
stack named ‘stud_details’:
(i) Push_element() - To Push an object containing name and age of
students who live in hostel “Ganga” to the stack
(ii) Pop_element() - To Pop the objects from the stack and display
them. Also, display “Stack Empty” when there are no elements in the
stack.
For example:
If the lists of customer details are:
[“Barsat”,17,”Ganga”]
[“Ruben”, 16,”Kaveri”]
[“Rupesh”,19,”Yamuna”]
The stack should contain
7
[“Barsat”,17,”Ganga”]
The output should be:
[“Barsat”,17,”Ganga”]
Stack Empty
OR
SECTION D
31
Hi-tech Training center, a Mumbai based organization is planning to
expand their training institute to Chennai. At Chennai compound,
they are planning to have three different blocks for admin, training
and accounts related activities. As a network consultant you have to
suggest some network related solutions to the organization
i) Suggest the most suitable block to house the server at Chennai block for 1
best and effective connectivity.
Suggest the type of network for the new training institute and draw
ii) 1
the cable layout for the Chennai office
Suggest a hardware/software that would provide the data security for entire network of Chennai
1
iii) region.
Suggest a device that shall be needed to provide wireless internet access to all smart
1
iv) phones/laptop users in Chennai office.
Suggest the protocol used for video conferencing between Chennai
1
v) office and Mumbai office
32. (a) Write the output of the code given below: 2+3
val=4
def findval(m,n=10):
val=0
val=val+m*n
a=10
b=20
findval(a,b)
print(val,end="-")
findval(a)
print(val,end="-")
(b) The code given below inserts the following record in the table
Employee:
cursor=_______________________#STATEMENT1
empid=int(input("enter Empid"))
name=input("enter name")
salary=float(input("ENTER SALARY"))
result = __________________________#STATEMENT2
___________________________________#STATEMENT3
OR
(b) The code given below reads the following record from the table
named Employee and displays only those records who have Salary
greater than 25000:
import mysql.connector
10
connection = mysql.connector.connect(host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=________________________#STATEMENT1
_________________________________________#STATEMENT2
records = _____________________________#STATEMENT3
for row in records:
print("Empid",row[0],end=" ")
print("name",row[1],end=" ")
print("salary",row[2],end=" ")
print()
OR
SECTION E
34. Rahul created following table TRAVEL to store the travel details 1+1+2
11
Based on the data given above answer the following questions:
13