XIIComp - Sc. 15 Sample Papers
XIIComp - Sc. 15 Sample Papers
XIIComp - Sc. 15 Sample Papers
(जम्मू संभाग )
SAMPLE PAPER
FOR CLASS XII
COMPUTER SCIENCE (083)
Section A
1 Write full form of CSV. 1
2 Which is valid keyword? 1
a. Int b. WHILE c.While d.if
3 Which of the following is not a valid identifier name in Python? 1
a) 5Total b) _Radius c) pie d)While
4 Consider the following expression: 1
51+4-3**3//19-3
Which of the following will be the correct output if the expression is evaluated?
a. 50
b. 51
c. 52
d. 53
5 Select the correct output of the code: 1
Str=“Computer”
Str=Str[-4:]
print(Str*2)
a. uter
b. uterretu
c. uteruter
d. None of these
6 Which module is imported for working with CSV files in Python? 1
a. csv
b. python-csv connector
c. CSV
d. python.csvconnector
7 Fill in the blank: 1
_____ command is used to update records in the MySQL table.
(a) ALTER (b) UPDATE (c) MODIFY (d) SELECT
8 Which command used to fetch rows from the table in database? 1
(a) BRING (b) FETCH (c) GET (d) SELECT
9 Which of the following statement(s) would give an error after executing the following 1
code?
print(9/2) # Statement-1
print(9//2) # Statement-2
print(9%%2) # Statement-3
print(9%2) # Statement-4
OR
def CALLME(n1=1,n2=2):
n1=n1*n2
n2+=2
print(n1,n2)
CALLME()
CALLME(3)
OR
mylist = [2,14,54,22,17]
tup = tuple(mylist)
for i in tup:
print(i%3, end=",")
OR
Section-C
26 a. Consider the following tables Trainer and Course: 1+2
b. Write the Outputs of the MySQL queries (i) to (iv) based on the given above tables:
i. SELECT DISTINCT(CITY) FROM TRAINER WHERE SALARY>80000;
ii. SELECT TID, COUNT(*), MAX(FEES) FROM COURSE GROUP BY TID
HAVING COUNT(*)>1;
iii. SELECT T.TNAME, C.CNAME FROM TRAINER T, COURSE C WHERE
T.TID=C.TID AND T.FEES<10000;
iv. SELECT COUNT(CITY),CITY FROM TRAINER GROUP BY CITY;
27 Write a method/function COUNTLINES_ET() in python to read lines from a text file 3
REPORT.TXT, and COUNT those lines which are starting either with ‘E’ or starting
with ‘T’ and display the Total count separately.
For example:
If REPORT.TXT consists of
“ENTRY LEVEL OF PROGRAMMING CAN BE LEARNED FROM PYTHON. ALSO, IT
IS VERY FLEXIBLE LANGUGAE. THIS WILL BE USEFUL FOR VARIETY OF
USERS.”
Then, Output will be:
No. of Lines with E: 1
No. of Lines with T: 1
OR
Write a method/ function SHOW_TODO() in python to read contents from a text file
ABC.TXT and display those lines which have occurrence of the word ‘‘TO’’ or
‘‘DO’’.
For example :
If the content of the file is
“THIS IS IMPORTANT TO NOTE THAT
SUCCESS IS THE RESULT OF HARD WORK.
WE ALL ARE EXPECTED TO DO HARD WORK.
AFTER ALL EXPERIENCE COMES FROM HARDWORK.”
OR
i. Suggest the most suitable location to install the main server of this institution
to get efficient connectivity.
ii. Suggest by drawing 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 each
computer installed in every building out of the following network cables:
Coaxial Cable, Ethernet Cable, Single Pair, Telephone Cable
v. Suggest the type of network implemented here.
32 (a) Write the output of following python code: 2+3
def result(s):
n = len(s)
m=''
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m + s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '#'
print(m)
result('Cricket')
(b) Avni is trying to connect Python with MySQL for her project. Help her to write the
python statement on the following:
i. Name the library, which should be imported to connect MySQL with Python.
ii. Name the function, used to run SQL query in Python.
iii. Write Python statement of connect function having the arguments values as :
Host name :192.168.11.111
User : root
Password: Admin
Database : MYPROJECT
OR
(a) Find the output
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print(Msg3)
b) Your friend Jagdish is writing a code to fetch data from a database Shop and table
name Products using Python. He has written incomplete code. You have to help him
write complete code:
import __________ as m # Statement-1
object1 = m.connect(
host="localhost",
user="root",
password="root",
database="Shop"
)
object2 = object1._____ # Statement-2
query = '''SELECT * FROM Products WHERE NAME LIKE "A%";'''
object2._____(query) # Statement-3
object1.close()
33 What is the advantage of using pickle module? 2+3
Write a program to write into a CSV file “one.csv” Rollno, Name and Marks separated
by comma. It should have header row and then take input from the user for all following
rows. The format of the file should be as shown if user enters 2 records.
Roll.No,Name,Marks
20,Ronit,67
56,Nihir,69
OR
What is difference between tell() and seek() methods?
Write a program to read all content of “student.csv” and display records of only those
students who scored more than 80 marks. Records stored in students is in format :
[Rollno, Name, Marks]
34 ABC Gym has created a table TRAINER. Observe the table given below and answer the 1+1
following questions accordingly. +2
SECTION A
1 State True or False 1
“The characters of string will have two-way indexing.”
2 Which of the following is the valid variable name? 1
(a) f%2 (b) 20ans (c) ans (d) $ans
3 What will be the output of the following code? 1
D1={1: “One”,2: “Two”, 3: “C”}
D2={4: “Four”,5: “Five”}
D1.update(D2)
print (D1)
a) {4:’Four’,5: ‘Five’}
b) Method update() doesn’t exist for dictionary
c) {1: “One”,2: “Two”, 3: “C”}
d) {1: “One”,2: “Two”, 3: “C”,4: ‘Four’,5: ‘Five’}
4 Evaluate the expression given below if A=16 and B=15. 1
A % B // A
a) 1 b) 0.0 c) 0 d) 1.0
5 Select the correct output of the following code : 1
s=“I#N#F#O#R#M#A#T#I#C#S”
L=list(s.split(‘#’))
print(L)
a) [I#N#F#O#R#M#A#T#I#C#S]
b) [‘I’, ‘N’, ‘F’, ‘O’, ‘R’, ‘M’, ‘A’, ‘T’, ‘I’, ‘C’, ‘S’]
c) [‘I N F O R M A T I C S’]
d) [‘INFORMATICS’]
6 Which of the following are the modes of both writing and reading in binary format in file? 1
a) wb+
b) w
c) w+
d) wb
7 Fill in the blank 1
_____________ command is used to modify the attribute datatype or size in a table structure.
a) update b) alter c) insert d) None of these
8 Which of the following clause is used to sort records in a table? 1
a) GROUP
b) GROUP BY
c) ORDER BY
d) ORDER
9 Which of the following statement(s) would give an error after executing the following code? 1
str= “Python Programming” #statement 1
x= ‘2’ #statement 2
print(str*2) #statement 3
print(str*x) #statement 4
a) statement 1
b) statement 2
c) statement 3
d) statement 4
10 Fill in the blank: 1
_________ constraint is used to restrict entries in other table’s non key attribute, whose values
are not existing in the primary key of reference table..
a) Primary Key
b) Foreign Key
c) Candidate Key
d) Alternate Key
11 A text file student.txt is stored in the storage device. Identify the correct option out of the 1
following options to open the file in read mode.
i. myfile = open('student.txt','rb')
ii. myfile = open('student.txt','w')
iii. myfile = open('student.txt','r')
iv. myfile = open('student.txt')
a) only i
b) both i and iv
c) both iii and iv
d) both i and iii
12 Fill in the blank: 1
_______________ define rules regarding the values allowed in columns and is the standard
mechanism for enforcing database integrity.
a) Attribute
b) Constraint
c) Index
d) Commit
13 Fill in the Blank 1
________________ is the networking device that connects computers in a network by using
packet switching to receive, and forward data to the destination.
a) Switch b)Hub c) Repeater d) Router
14 What will the following expression be evaluated to in Python? 1
print(6*3 / 4**2//5-8)
(a) -10 (b) 8.0 (c) 10.0 (d) -8.0
15 The operation whose result contains all pairs of tuples from the two relations, regardless of 1
whether their attribute values match.
a) Join
b) Intersection
c) Union
d) Cartesian Product
16 To create a connection between MYSQL database and Python application connect() function is 1
used. Which of the following are mandatory arguments required to connect any database from
Python.
a) Username, Password, Hostname, Database Name, Port
b) Username, Password, Hostname
c) Username, Password, Hostname, Database Name
d) Username, Password, Hostname, Port
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):- All the keyword arguments passed must match one of the arguments accepted by 1
the function
C
Reasoning (R):- You cannot change the order of appearance of the keyword.
18 Assertion (A): CSV file is a human readable text file where each line has a number of fields, 1
separated by commas or some other delimiter. B?
Reason (R): writerow() function can be used for writing into writer object.
SECTION B
19 Raman has written a code to find its sum of digits of a given number passed as parameter to 2
function sumdigits(n). His code is having errors. Rewrite the correct code and underline the
corrections made.
def sumdigits(n):
d=0
for x in str(n): RANGE N
d=d+x
return d
n=int(input(‘Enter any number”))
s=sumdigits(n)
print(“Sum of digits”,s)
20 Write two points of difference between Switch and Router. 2
OR
Write two points of difference between Web Server and Web Browser.
21 (a) Given is a Python List declaration: 1
list= [10, 20, 30, 40, 50, 60, 70, 80]
print(list[ : : 2])
(b) Write the output of the code given below:
squares = {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} 1
16
print(squares.pop(4))
22 Explain the use of ‘Primary Key’ in a Relational Database Management System. Give example to 2
support your answer.
23 (a) Write the full forms of the following: 2
(i) POP3 (ii) TCP/IP post office protocol
(b) What is the use of VoIP?
24 Predict the output of following code: 2
def fun(x):
x[0] = 5
return x
g = [10,11,12] [5,11,12] ,[5,11,12]
print(fun(g),g)
OR
test_list = [5, 6, 7]
test_tup = (9, 10)
(9,10,5,6,7)
res = tuple(list(test_tup) + test_list)
print(str(res))
25 Differentiate between char and varchar in SQL with appropriate examples. 2
OR
What are different types of SQL Aggregate Functions? Give two examples.
SECTION C
26 (a) Consider the following tables – Uniform and Cost: 1+2
Uniform
UCODE UNAME UCOLOR
1 Shirt White
2 Pant Grey
3 Tie Blue
4 Shocks Blue
Cost
UCODE SIZE PRICE
1 L 580
1 M 600
2 L 800
2 M 810
(b) Write the output of the queries (i) to (iv) based on the table “Product”, showing details of
products being sold in a grocery shop.
Pcode Pname Uprice Manufacturer
P01 Washing Powder 120 Surf
P02 Toothpaste 54 Colgate
P03 Soap 25 Lux
P04 Toothpaste 65 Pepsodent
P05 Soap 38 Dove
P06 Shampoo 245 Dove
CUSTOMER
CUSTID NAME PRICE QTY CID
101 ROHAN 70000 20 222
102 DEEPAK 50000 10 555
103 MOHAN 30000 5 111
104 SAHIL 35000 3 333
105 NEHA 25000 7 444
106 SOHAN 20000 5 333
107 ARUN 50000 15 555
i) SELECT COUNT(*) , CITY FROM COMPANY GROUP BY CITY;
ii) SELECT MIN(PRICE), MAX(PRICE) FROM CUSTOMER WHERE QTY>10;
iii) SELECT PRODUCTNAME, CITY, PRICE FROM COMPANY, CUSTOMER WHERE
COMPANY. CID=CUSTOMER.CID AND PRODUCTNAME= “MOBILE”;
iv) SELECT CUSTOMER.NAME, CITY, PRICE FROM COMPANY, CUSTOMER WHERE
COMPANY. CID=CUSTOMER.CID AND PRICE>25000;
(b) Write command to show all the tables in a database.
29 Write a function listchange(Arr,n)in Python, which accepts a list Arr of numbers and n is an 3
numeric value depicting length of the list. Modify the list so that all even numbers doubled and
odd number multiply by 3
Sample Input Data of the list: Arr= [ 10,20,30,40,12,11], n=6
Output: Arr = [20,40,60,80,24,33]
30 A list contains following record of a student: [Rno, Name, Dob, Class] 3
Write the following user defined functions to perform given operations
on the stack named ‘status’:
(i) Push_element() - To Push an record of student 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.
OR
Write a function in Python, Push(book) where, book is a dictionary containing the details of a
book in form of {bookno : price}.
The function should push the book in the stack which have price greater than 300. Also display
the count of elements pushed into the stack.
For example:
If the dictionary contains the following data:
Dbook={"Python":350,"Hindi":200,"English":270,"Physics":600, “Chemistry”:550}
The stack should contain
Chemistry
Physics
Python
The output should be:
The count of elements in the stack is 3
SECTION D
31 Eduminds University of India is starting its first campus in a small town Parampur of central India 5
with its centre admission office in Delhi. The university has three major buildings comprising of
Admin Building, Academic Building and Research Building in the 5 km area campus.
As a network expert, you need to suggest the network plan as per (a) to (e) to the authorities
keeping in mind the distance and other given parameters.
b) The code given below inserts the following record in the table Employee:
Empno – integer
EName – string
Desig – integer
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is Password
The table exists in a MYSQL database named Bank.
The details (Empno, Ename, Design and Salary) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to query string.
Statement 3- to execute insert query for employee table
import mysql.connector
mydb=mysql.connector.connect(host='localhost',user='root',passwd='Password',database='bank')
mycursor=_________________ # statement1
eno=int(input('enter Employee no'))
nm=input('enter Employee name')
d=input('enter Designation)
s=int(input(‘Enter salary’))
rtup=(eno,n,d,s)
rq=’’’insert into Employee (Empno, Ename, Design,Salary)
values (___________________)’’’ #statement2
mycursor.________________ #statement 3
mydb.commit()
print("Data Added successfully"
OR
a) Predict the output of the following code:
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@Python3.0')
b) The code given below reads the following record from Table named Employee and display
those record salary >= 30000 and <= 90000:
Empno – integer
EName – string
Desig – integer
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is Password
The table exists in a MYSQL database named Bank.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to query string.
Statement 3- to execute the query that extracts records of those Employees whose salary
>=30000 and <=90000.
import mysql.connector
mydb=mysql.connector.connect(host='localhost',user='root',passwd='Password',database='bank')
mycursor=_________________ # statement1
mycursor.________________ #statement 2
data= __________________ # statement 3
for x in data:
print(x)
33 What is the use of tell() function? 5
Write a program in Python that defines and calls the following user defined functions:
i. Add(): to add the record of a student to a csv file “record.csv”. Each record should be
with field elements [admno,sname,class]
ii. Count(): to count the number of students studying in class 12
OR
Give a difference between dump and load function. Write a program in Python that defines and
calls the following user defined functions:
i. Add(): to add the record of an animal to a csv file “animal.csv”. Each record should be
with field elements [animalname, animaltype, animalfood]
ii. Search(): to print all the animal names who eat grass as their food.
SECTION E
34 Arjun creates a table Employee with a set of records to maintain their Inventory. After 1+1+2
creation of table, he entered data of 7 employees in the table.
EMPNO NAME DEPT SALARY
1021 Radhika sales 5000
1022 Anu dev 12000
1023 Rajesh support 8000
1024 Arunag dev 20000
1026 Manisha sales 7000
1027 Disha support 4000
1035 Sanjay dev 34000
(a) Identify the attribute best suitable to be declared as a primary key
(b) If two columns and two rows are added what will be the degree and cardinality of the
table Employee
(c) i) Insert the following data into the attributes empID, empName and empDept
respectively
in the given table SUDENT empID = 1042, empName = “Abhinav” and empDept =
“support”
ii) Write a command display structure of table employee.
OR
(c) i) Write a command to add new column bonus to Employee Table
ii) Write SQL statement to update the Bonus of all employees by 20% of salary.
35 Aditya is a Python programmer. He has written a code and created a binary file student.dat with
rollno, name, class and marks. The file contains 10 records. He now has to search record based on
rollno in the file student.dat
25 What do you understand by ORDER BY in SQL? Explain the use of Where clause with 2
SELECT.
OR
What do you mean by degree and cardinality of table?
Section-C
26 a) Table: EMPLOYEES 2+1
Empid Firstname Lastname Address City
010 Ravi Kumar Raj nagar GZB
105 Harry Waltor Gandhi nagar GZB
152 Sam Tones 33 Elm St. Paris
215 Sarah Ackerman 440 U.S. 110 Upton
244 Manila Sengupta 24 Friends street New Delhi
300 Robert Samuel 9 Fifth Cross Washington
335 Ritu Tondon Shastri Nagar GZB
400 Rachel Lee 121 Harrison St. New York
441 Peter Thompson 11 Red Road Paris
Table: EMPSALARY
Empid Salary Benefits Designation
010 75000 15000 Manager
105 65000 15000 Manager
152 80000 25000 Director
215 75000 12500 Manager
400 32000 7500 Salesman
441 28000 7500 salesman
501 18000 6500 Clerk
i) 20#25#25#
ii) 30#40#70#
iii) 15#60#70#
iv) 35#40#60#
b) The code given below inserts the following record in the table Student:
Empno – integer
EName – string
Designation – integer
Salary – integer
Bonus - 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 Employee.
The details (Empno, EName, Designation, Salary and Bonus) 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
Employee.
Statement 3- to add the record permanently in the database
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root", password="tiger",
database="Employee")
mycursor=_________________ #Statement 1
eno=int(input("Enter Employee Number: "))
Ename=input("Enter Employee Name: ")
Designation=input("Enter Designation: "))
Salary=int(input("Enter Salary: "))
Bonus=int(input("Enter Bonus: "))
querry="insert into employee values({},'{}',{},{})".
format(eno,ename,designation,bonus)
______________________ #Statement 2
______________________ # Statement 3
print("Employee Data Added successfully")
OR
a) Predict the output:
def func(S):
k=len(S)
m=''
for i in range(0,k):
if S[i].isalpha( ):
m=m+S[i].upper( )
elif S[i].isdigit( ):
m=m+'0'
else:
m=m+'#'
print(m)
func("Python 3.9")
b) What are the basic steps to connect Python with MYSQL using table Members
present in the database ‘Society’?
33 Rohit, a student of class 12th, is learning CSV File Module in Python. During examination, 5
he has been assigned an incomplete python code (shown below) to create a CSV File
'Student.csv' (content shown below). Help him in completing the code which creates the
desired CSV File. CSV File
1,AKSHAY,XII,A
2,ABHISHEK,XII,A
3,ARVIND,XII,A
4,RAVI,XII,A
5,ASHISH,XII,A
Incomplete Code
import_____ #Statement-1
fh = open(_____, _____, newline='') #Statement-2
stuwriter = csv._____ #Statement-3
data = []
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
data.append(header)
for i in range(5):
roll_no = int(input("Enter Roll Number : "))
name = input("Enter Name : ")
Class = input("Enter Class : ")
section = input("Enter Section : ")
rec = [_____] #Statement-4
data.append(rec)
stuwriter. _____ (data) #Statement-5
fh.close()
Answer the following questions
i. Write the suitable code for blank space in line marked as Statement-1
ii. Write the missing code for blank space in line marked as Statement-2?
iii. Write function name (with argument) that should be used in the blank space of line
marked as Statement-3
iv. Complete the statement-4 with suitable code.
v. Write the function name that should be used in the blank space of line marked as
Statement-5 to create the desired CSV File?
OR
Your teacher has given you a method/function FilterWords() in python which read lines
from a text file NewsLetter.TXT, and display those words, which are lesser than 4
characters. Your teachers intentionally kept few blanks in between the code and asked
you to fill the blanks so that the code will run to find desired result. Do the needful with
the following python code.
def FilterWords():
c=0
file=open('NewsLetter.TXT', '_____') #Statement-1
line = file._____ #Statement-2
word = _____ #Statement-3
for c in word:
if _____: #Statement-4
print(c)
_________ #Statement-5
FilterWords()
i. Write mode of opening the file in statement-1?
ii. Fill in the blank in statement-2 to read the data from the file.
iii. Fill in the blank in statement-3 to read data word by word.
iv. Fill in the blank in statement-4, which display the word having lesser than 4
v. Fill in the blank in Statement-5 to close the file.
SECTION E
34 A department is considering to maintain their worker data using SQL to store the data. As 4
a Database Administrator, Karan has decided that:
Name of the database –Department
Name of the table –Worker
The attributes of Worker are as follows:
WORKER_ID – CHARACTER OF SIZE 3
FIRST_NAME – CHARACTER OF SIZE 10
LAST_NAME – CHARACTER OF SIZE 10
SALARY – NUMERIC
JOINING_DATE – DATE
WORKER_ID FIRST_NAME LAST_NAME SALARY JOINING_DATE DEPARTMENT
001 MONIKA ARORA 100000 2014-02-20 HR
002 NIHARIKA DIWAN 80000 2014-06-11 Admin
003 VISHAL SINGHAL 300000 2014-02-20 HR
004 AMITABH SINGH 500000 2014-02-20 Admin
005 VIVEK BHATI 500000 2014-06-11 Admin
006 VIPUL DIWAN 200000 2014-06-11 Account
007 SATISH KUMAR 75000 2014-02-20 Account
008 MONIKA CHAUHAN 80000 2014-04-11 Admin
a) Karan wants to remove all the data from table WORKER from the database
department. Write the command to delete above said information.
b) Identify the attribute best suitable to be declared as a primary key.
c) (i) Karan wants to increase the size of the FIRST_NAME column from 10 to 20
characters. Write an appropriate query to change the size.
(ii) Write a query to display the structure of the table Worker, i.e. name of the
attribute and their respective data types
OR (only for part c)
Write command to create above table
35 Amritya Seth is a programmer, who has recently been given a task to write a python code 4
to perform the following binary file operations with the help of two user defined
functions/modules:
a. AddStudents() to create a binary file called STUDENT.DAT containing student
information – roll number, name and marks (out of 100) of each student.
b. GetStudents() to display the name and percentage of those students who have a
percentage greater than 75. In case there is no student having percentage > 75 the
function displays an appropriate message. The function should also display the average
percent.
KENDRIYA VIDYALAYA SANGATHAN, JAMMU REGION
SAMPLE PAPER SET 4
CLASS – XII SUBJECT: Computer Science-083
Total Time- 3 Hours Total Marks- 70
General Instructions:
SECTION A
1. Find the invalid identifier from the following 1
a) MyName b) True c) 2ndName d) My_Name
2. (Which of the following is a mutable datatype in Python? 1
(a) String (b) List (c)Integer (d) Tuple
3. Given the following dictionaries 1
D1={"Exam":"ICSCE", "Year":2023, "Total":500}
Which statement will add a new value pair (Grade: “A++”) in dictionary D1?
a. D1.update(“REMARK” : “EXCELLENT”)
b. D1 + {“REMARK” : “EXCELLENT”}
c. D1[“REMARK”] = “EXCELLENT”
d. D1.merge({“REMARK” : “EXCELLENT”})
4. Consider the given expression: 1
not False or 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
5. Select the correct output of the code: 1
Str = "KENDRIYA VIDYALAYA SANGATHAN JAMMU REGION"
Str = Str.split()
NewStr = Str[0] + "#" + Str[1] + "#" + Str[4]
print (NewStr)
a) KENDRIYA#VIDYALAYA#SANGATHAN# JAMMU
b) KENDRIYA#VIDYALAYA#SANGATHAN
c) KENDRIYA#VIDYALAYA# REGION
d) None of these
1
6. Assume that the position of file pointer is at the beginning of 3 rd line in a text file. 1
Which of the following option can be used to read all remaining lines?
(a) file.read() (b) file.readlines() (c) file.readline() (d) None of these
7. Fill in the blank: 1
command is used to change datatype of a field in table in SQL.
(a) update (b)remove (c) alter (d)drop
8. ________ in a table represent relationship among a set of values. 1
11. The _________ method of _____ module is used to read data from binary file : 1
a) read(), binary b) load(), pickle
c) dump(), binary d) dump(), pickle
12. Which keyword can be used to show only different values in a particular 1
column in a table?
a) DESCRIBE b) DISTINCT c) UNIQUE d)NULL
13. Fill in the blank: 1
Which of the following statement are true about URL?
(a) URL means Uniform Resource Locator b) We can enter URL into address bar
(c) An example of URL is top@gg.com (d) Both A and B
14. What will the following expression be evaluated to in Python? 1
print(75.0 / 4 + (2** 3))
(a) 20.5 (b)20.05 (c) 18.25 (d) 17.75
15. Which function is used to display the Smallest largest value from the selected column 1
of table in a database?
a) Small() b) Least() c) Min() d) None of above()
16. To establish a connection between Python and MySQL database, which of the following 1
method is used?
a) connector() b) connect() c) cont() d) con()
2
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):- Keyword arguments are related to function call statement. 1
Reasoning (R):- When we use keyword argument in a function call, the caller
identifies the argument by the parameter.
18. Assertion (A): CSV (Comma Separated Values) stands for Comma Separated values File. 1
Reason (R): CSV files are common file format for transferring and storing data.
SECTION
B
19. Correct Code is 2
def DigitSum():
n = int( input("Enter number :: ")
dsum = 0
while n > 0
d = n % 10
dsum =dsum + d
n = n //10
RETURN dsum
20. What is an E-mail? Write two advantages of an E-mail. 2
OR
Write two points of difference between Bus topology and Star topology.
3
24. Predict the output of the Python code given below: 2
L1 =[]
def display(N):
for K in N:
if K % 2 ==0:
L1.append(K//2)
else:
L1.append(K*2)
L = [11,22,33,45,55,66]
print(L)
display(L)
print(L1)
OR
Predict the output of the Python code given below:
4
27 Write a function in Python to read from a text file “INDIA.TXT”, to find and display 3
those words of file which have 3 characters. For example, If the “INDIA.TXT” contents
are as follows:
“India is the fastest growing economy.
India is looking for more investments around the globe.”
The output of the function should be: the for the
28 a) Write the outputs of the SQL queries (i) to (iv) based on the relations 3
BOOK and ISSUES given below:
Table : Book
Quanti
Book_id Book name Author_name Publisher Price Type ty
C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5
William
F0001 The Tears Hopkins First Pub 650 Fiction 20
T0001 My First c++ Brain & Brooke FPB 350 Text 10
C++ Brain
T0002 works A.W. Rossaine TDH 350 Text 15
F0002 Thunderbolts Anna Roberts First Publ. 750 Fiction 50
Table : issued
Book_Id Quantity Issued
T0001 4
C0001 5
F0001 2
i. Select Count(*) from Books
ii. Select Max(Price) from books where quantity >=15
iii. Select book_name, author_name from books where publishers=’First Publ.’
iv. Select a.book_id,a.book_name,b.quantity_issued from books a, issued b
where a.book_id=b.book_id
5
30 Consider a binary file Employee.dat containing details such as 3
empno:ename:salary(separator ‘:’). Write a Python function Readfile() to display details
of those employees who are earning between 20000 and 40000(both values inclusive)
also count how many records are available in the file.
OR
A binary file named “TEST.dat” has some records of the structure [TestId, Subject,
MaxMarks, ScoredMarks]
Write a function in Python named DisplayAvgMarks(Sub) that will accept a subject as an
argument and read the contents of TEST.dat. The function will calculate & display the
Average of the ScoredMarks of the passed Subject on
screen.
SECTION D
31 Software Development Company has set up its new center at Raipur for its office and 5
web based activities. It has 4 blocks of buildings named Block A, Block B, Block C, Block
D.
No of Computers in each Block Distance between various blocks
Block A 25 Block A to Block B 60 Mtrs
Block B 50 Block B to Block C 40 Mtrs
Block C 125 Block C to Block A 30 Mtrs
Block D 10 Block D to Block C 50 Mtrs
a) Suggest the most suitable place (i.e. block) to house the server of this company
with a suitable reason.
b) Suggest the ideal layout to connect all the blocks with a wired connectivity.
c) Which device will you suggest to be placed/installed in each of these blocks to
efficiently connect all the computers within these blocks.
d) Suggest the placement of a repeater in the network with justification.
The company is planning to link all the blocks through a secure and
high speed wired medium. Suggest a way to connect all the blocks.
encrypt('KVS@Jammu')
(b) The code given below inserts the following record in the table Item:
6
ItemNo – integer Name –
string
Price – integer
Qty – integer
def sql_data():
con1=mysql.connect(host="localhost", user="root",
password="omega", database="resource")
mycursor= con1.cursor()
ItemNo = int(input("Enter ItemNo :: "))
Name = input("Enter name :: ")
Price = int(input("Enter price :: "))
Qty = int(input("Enter Qty :: "))
querry="insert into student
values({}, '{}',{ }, {})".format(Itemno, Name, Price, Qty)
_______________________ #Statement 2
_______________________ # Statement 3
print("Data Added successfully")
OR
(a) Predict the output of the code given below:
s ="Back2Basic"
n = len(s)
NS =""
for i in range(0, n):
if (s[i] in “áeiou”):
NS = NS + s[i].upper()
elif (s[i] >= 'a' and s[i] <= 'z'):
NS = NS +s[i].lower()
else:
NS = NS + '#'
print(NS)
(b) The code given below reads the following record from the table named student
and displays only those records who have marks greater than 85:
RollNo – integer Name –
string Class – integer
Marks – integer
7
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is tiger
The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
def sql_data():
con1=mysql.connect(host="localhost",user="root", password="tiger",
database="school")
mycursor= #Statement 1
print("Students with marks greater than 85 are :")
_________________________ #Statement 2
data = #Statement 3
for i in data:
print(i)
print()
33. a) What do you mean by a csv file? 5
(1+2+2
)
b) A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price].
a) Write a user defined function CreateFile() to input data for a record and add to
Book.dat file.
b) 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 are
stored in the binary file “Book.dat”
OR
b Write a function in python, pushme (stock, item) and popme(stock ) to add a new
item and delete an item from the stock, considering them to act as push and pop
operations of the stack.
SECTION E
8
34 Nawal Rao creates a table Emp 1+1+2
(i) Identify the most appropriate column, which can be considered as Primary
key.
(ii) If one column is added and 2 rows are deleted from the table EMP, 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
EmpNo- 8, Name- Ravi, Dept- Sales, Design- Mgr, Gender- M, Salary –
34000, City- Delhi .
b. Increase the Salary of the Employees who are in Acct department
by 3%.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of Employees who lives in Delhi.
b. Add a column MobNo in the table with datatype as
varchar with 10 characters
35 Aditya has written a code and created a binary file record.dat with ItemNo, Itname and
Price.
As a Python expert, help him to complete the following code based on the requirement
given above:
Add_Rec()
1
a) Name the Module that Aditya should import in Statement 1
b) In which mode, Aditya should open the file to add data into the file in statement 1
2.
2
c) Fill in the blank in statement 3 to fetch the data to a file and statement 4 to close
the file.
9
KENDRIYA VIDYALAYA SANGATHAN, JAMMU REGION
General Instructions:
Q10 If the following code is executed, what will be the output of the following code? 1
. name="Kendriya Vidyalaya Sangathan"
print(name[10:19])
(a) Kendriya
(b) Vidyalaya
(c) Sangathan
(d) nry iy
Q11 Which of the following types of table constraints will prevent the printing 1
.
of duplicate values after the Select statement fetches data from table?
(a) Unique
(b) Distinct
(c) Primary Key
(d) NULL
Q12 What is the use of tell () function in python 1
.
Q13 Switch is a 1
. A. Broadcast device B. Unicast device C. Multicast device D. None of the above
Q14 What will the following expression be evaluated to in python? 1
. print(15.0/4+(8*3.0))
(a) 14.5
(b) 14.0
(c) 27.7
(d) 15.5
Q15 Which function is used to display the sum of column of records from table in a 1
. database?
(a) sum(*)
(b) total(*)
(c) count(*)
(d) return(*)
Q16 What is the use of connect () function ? 1
.
Q17 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
(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 match the 1
number and order of arguments as defined in the function definition,
such arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains
default argument(s) followed by positional argument(s).
Q18 Assertion (A): CSV (Comma Separated Values) is a file format for data storage 1
. which looks like a text file.
Reason (R): The information is organized with one record on each line and each
Section-B
Q19 Mr. Ram has written a code to input two numbers and swap the number using 2
. function but he has some error in his coding, so help him to rectify the errors
and rewrite the correct code.
Def swap(a,b)
c=a
a=b
b=c
print("a is",a,"b is",b )
#main()
a=int(input("enter in a "))
b=int(input("enter in b"))
Swap(a,b)#calling a function
Q20 What is the difference between a hub and a switch in context of computer 2
.
networking devices?
OR
Differentiate between HTTP and FTP.
Q21 Evaluate the following expressions: 2
.
(a) 5 // 10 * 9 % 3 ** 8 + 8 – 4
(b) 65 > 55 or not 8 < 5 and 0 != 55
Q22 Explain the use of ‘Foreign Key’ in a Relational Database Management System. 2
.
Give example to support your answer.
Q23 Expand the following terms: 2
. IMAP sHTTP URL POP3
Q24 Predict the output of the Python Code given below: 2
. d={"Rohan":67,"Ahasham":78,"naman":89,"pranav":79}
print(d)
sum=0
for i in d:
sum+=d[i]
print(sum)
print("sum of values of dictionaries",sum)
or
(i) def check(x,y):
if x != y:
return x+5
else:
return y+10
print(check(10,5))
Q25 Write the full forms of DDL and DML. Write any two commands of DDL in SQL. 2
. Or
In SQL, write the name of the aggregate function which is used to calculate &
display the sum of numeric values in an attribute of a relation.
Section- C
Q26 Write the outputs of the SQL queries (i) to (iii) based on the given tables: 3
.
Table: Event
EventID Event NumPerformers CelebrityID
101 Birthday 10 C102
102 Promotion Party 20 C103
103 Engagement 12 C102
104 Wedding 15 C104
Table: Celebrity
CelebrityID Event Phone FeeCharged
C101 FaizKhan 9910154555 200000
C102 Sanjay Kumar 6546454654 250000
C103 Neera Khan 4654656544 300000
C104 Reena Bhatia 9854664654 100000
Q27 Write a function in Python that counts the number of “the” or “this” words 3
. present in a text file “myfile.txt”.
Example: If the “myfile.txt” contents are as follows:
This is my first class on Computer Science. File handling is the easiest topic for
me and Computer Networking is the most interesting one.
The output of the function should be: Count of the/this in file: 3
OR
Write a function countVowels() in Python, which should read each character of a
text file “myfile.txt”, count the number of vowels and display the count.
Example: If the “myfile.txt” contents are as follows:
This is my first class on Computer Science.
The output of the function should be: Count of vowels in file: 10
Q28 3
Q30 Two list Lname and Lage contains name of person and age of person 3
respectively. A list named Lnameage is empty. Write functions as details given
below
(i) Push_na() :- it will push the tuple containing pair of name and age
from Lname and Lage whose age is above 50
(ii) Pop_na() :- it will remove the last pair of name and age and also print
name and age of removed person. It should also print “underflow” if
there is nothing to remove
For example the two lists has following data
Lname=[‘narender’, ‘jaya’, ‘raju’, ‘ramesh’, ‘amit’, ‘Piyush’]
Lage=[45,23,59,34,51,43]
Block Computer
Human Resource 125
Finance 25
Conference 60
(a) What will be the most appropriate block where TUC should plan to install 1
their server?
(b) What will be the best possible connectivity out of the following to 1
connect its new office in Bengaluru with its London based office?
(i) Infrared
(ii) Satellite Link
(iii) Ethernet Cable
(c) Which of the following devices will you suggest to connect each
1
computer in each of the above blocks?
(i) Gateway
(ii) Switch
(iii) Hub
(iv) Modem
1
(d) Write names of any two popular open Source software which are used as
Operating Systems.
1
(e) Suggest an ideal layout for connecting these blocks/centers for a wired
connectivity
Q32 (a) Write the output of the code given below: 2+3
p=5
def sum(q,r=2):global
p p=r+q**2
print(p, end= '#')
a=10
b=5
sum(a,b)
sum(r=5,q=1)
(b)The given program is used to connect with MySQL abd show the name of the
all the record from the table “stmaster” from the database “oraclenk”. You are
required to complete the statements so that the code can be executed properly.
import _____.connector_as_pymysql
dbcon=pymysql._____________(host=”localhost”, user=”root”,
________=”sia@1928”)
if dbcon.isconnected()==False:
print(“Error in establishing connection:”)
cur=dbcon.______________()
query=”select * from stmaster”
cur.execute(_________)
resultset=cur.fetchmany(3)
for row in resultset:
print(row)
dbcon.______()
OR
s="welcome2cs"
n = len(s)m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):m =m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):m = m +s[i-1]
elif (s[i].isupper()): m = m +
s[i].lower()
else:
m = m +'&'
print(m)
(b) The code given below reads the following record from the tablenamed
student and displays only those records who have marks greater than 75:
RollNo – integer
Name – string
Clas – integer
Marks – integer
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="school")
mycursor= #Statement 1
print("Students with marks greater than 75 are :")
__________________________________________#Statement 2
data= #Statement 3
for i in data:
print(i)
print()
Q33 What is the advantage of using a csv file for permanent storage? 5
. Write a Program in Python that defines and calls the following userdefined
functions:
(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 mobileto store employee id, employeename and
employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSVfile
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:
General Instructions:
Q10 If the following code is executed, what will be the output of the following code? 1
. name="Kendriya Vidyalaya Sangathan"
print(name[2:13:2])
(a) Kendriya
(b) Vidyalaya
(c) Sangathan
(d) nry iy
Q11 Which of the following types of table constraints will prevent the printing of 1
.
duplicate values after the Select statement fetches data from table?
(a) Unique
(b) Distinct
(c) Primary Key
(d) NULL
Q12 The Correct syntax of seek() is: 1
.
(a) File_object.seek(offset[,reference_point])
(b) seek(offset[,referece_point])
(c) seek(offset,file_object)
(d) seek.file_object(offset)
Q13 (i) Expand the following: 1
. ARPANET, TCP/IP
Q14 What will the following expression be evaluated to in python? 1
. print(15.0/4+(8+3.0))
(a) 14.5
(b) 14.0
(c) 15
(d) 15.5
Q15 Which function is used to display the total number of records from table in a database? 1
. (a) sum(*)
(b) total(*)
(c) count(*)
(d) return(*)
Q16 To establish a connection between Python and sql database, connect() is used. Which of 1
. the following arguments may not necessarily be given while calling connect() ?
(a) host
(b) database
(c) user
(d) password
Q17 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
(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):-Serialization is the process of transforming data to a stream of bytes 1
Reasoning (R):-It is also known as Picking
Q18 Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks 1
. like a text file.
Reason (R): The information is organized with one record on each line and each
Section-B
Q19 Mr. Ram has written a code to input two numbers and swap the number using function 2
. but he has some error in his coding, so help him to rectify the errors and rewrite the
correct code.
Def swap(a,b)
c=a
a=b
b=c
print("a is",a,"b is",b )
#main()
a=int(input("enter in a "))
b=int(input("enter in b"))
Swap(a,b)#calling a function
Q20 What is the difference between a hub and a switch in context of computer networking 2
.
devices?
OR
Differentiate between HTTP and FTP.
Q21 Evaluate the following expressions: 2
.
(a) 5 // 10 * 9 % 3 ** 8 + 8 – 4
(b) 65 > 55 or not 8 < 5 and 0 != 55
Q22 Explain the use of ‘Foreign Key’ in a Relational Database Management System. Give 2
.
example to support your answer.
Q23 Define the following terms: 2
. Web server, Web Hosting
OR
Give two advantages and two disadvantages of bus topology.
Q24 Predict the output of the Python Code given below: 2
. d={"Rohan":67,"Ahasham":78,"naman":89,"pranav":79}
print(d)
sum=0
for i in d:
sum+=d[i]
print(sum)
print("sum of values of dictionaries",sum)
or
for i in range(1,3):
print('answer ',i,'is', i**2)
Q25 Write the full forms of DDL and DML. Write any two commands of DDL in SQL. 2
. Or
Categories the following commands as DDL or DML:
INSERT, UPDATE,ALTER,DROP
Section- C
Q26 Write the outputs of the SQL queries (i) to (iii) based on the given tables: 3
.
Table: Event
EventID Event NumPerformers CelebrityID
101 Birthday 10 C102
102 Promotion Party 20 C103
103 Engagement 12 C102
104 Wedding 15 C104
Table: Celebrity
CelebrityID Event Phone FeeCharged
C101 FaizKhan 9910154555 200000
C102 Sanjay Kumar 6546454654 250000
C103 Neera Khan 4654656544 300000
C104 Reena Bhatia 9854664654 100000
Q27 Write a user-defined function named count() that will read the 3
. contents of text file named “Story.txt” and count the number
of lines which starts with either “I‟ or “M‟. E.g. In the following
paragraph, there are 2 lines starting with “I‟ or “M‟:
OR
Write a function countmy( )in Python to read the text file “Story.txt” and
count the number of times “my” or “My” occurs in the file. For example if
the file “Story.TXT” contains:
“This is my website. I have displayed my preferences in the CHOICE
section.”
The countmy( ) function should display the output as: “my occurs 2 times”.
Q28 (a) Write the output of the following sql queries (i) to (iv) based on the relations 3
Teacher and Placement given below:
Table: Teacher
Table :Placement
P_ID Department Place
1 History Ahmedabad
2 Mathematics Jaipur
3 Computer Sc Nagpur
As a network expert, you are required to give best possiblesolutions for the given
queries of the university administration:-
1
(b) Suggest the most suitable building to house the server of this university
with a suitable reason.
Q32 (a) Write the output of the code given below: 2+3
p=5
def sum(q,r=2):global p
p=r+q**2
print(p, end= '#')
a=10
b=5 sum(a,b)
sum(r=5,q=1)
(b) The code given below inserts the following record in the tableStudent:
RollNo – integer
Name – string
Class– integer
Marks – integer
def sql_data():
con1=mysql.connect(host="localhost",user="root",password="tiger",database="s
chool")
mycursor= #Statement 1
rno=int(input("Enter Roll Number :: ")) name=input("Enter name :: ")
clas=int(input("Enter class :: ")) marks=int(input("Enter Marks :: "))
querry="insert into student
values({},'{}',{},{})".format(rno,name,clas,marks)
#Statement 2
# Statement 3
print("Data Added successfully")
OR
(b) The code given below reads the following record from the tablenamed student
and displays only those records who have marks greater than 75:
RollNo – integer
Name – string
Clas – integer
Marks – integer
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="_________") statement 1
mycursor= #Statement 2
print("Students with roll greater than 10 are :")
data= #Statement 3
for i in data:
print(i)
print()
Q33 What is the advantage of using a csv file for permanent storage? 5
. Write a Program in Python that defines and calls the following userdefined functions:
(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 mobileto store
employee id, employeename and employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSVfile 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:
(i) Identify the most appropriate column, which can be consideredas Primary
key.
(ii) If 3 columns are added and 2 rows are deleted from the tableresult, 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
Roll No- 110, Name- Aadit, Sem1- 470, Sem2-444, Sem3-475, Div – I.
b. Increase the SEM2 marks of the students by 3% whosename
begins with ‘N’.
import #Statement 1
def update_data():
rec={}
fin=open("record.dat","rb")
fout=open(" -------“) ") #Statement 2
found=False
eid=int(input("Enter employee id to update theirsalary :: "))
while True:
try:
rec= #Statement 3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enter new salary:: "))
pickle. #Statement 4
else:
pickle.dump(rec,fout)except:
break
if found==True:
print("The salary of employee id ",eid," hasbeen updated.")
else:
print("No employee with such id is not found")fin.close()
fout.close()
SECTION – A
1. Python identifiers are case sensitive. 1
a) True
b) False
2. Find the invalid identifier from the following: 1
a) None
b) address
c) Name
d) Pass
3. Which is the correct form of declaration of dictionary? 1
a) Day={1:’Monday’,2:’Tuesday’,3:’Wednesday’}
b) Day={‘1:Monday’,’2:Tuesday’,’3:Wednesday’}
c) Day=(1:’Monday’,2:’Tuesday’,3:’Wednesday’)
d) Day=[1:’Monday’,2:’Tuesday’,3:’Wednesday’]
4. What is the output of ‘hello’+1+2+3? 1
a) hello123
b) hello6
c) Error
d) Hello+6
5. What will be the output for the following Python statement? 1
T=(10,20,[30,40,50],60,70)
T[2][1]=100
print(T)
a) (10,20,100,60,70)
b) (10,20,[30,100,50],60,70)
c) (10,20,[100,40,50],60,70)
d) None of these
6. Which of the following is not a correct Python statement to open a text file 1
“Notes.txt” to write content into it?
a) F=open(‘Notes.txt’,’w’)
b) F=open(‘Notes.txt’,’a’)
c) F=open(‘Notes.txt’,’A’)
d) F=open(‘Notes.txt’,’w+’)
7. Which command is used to add a new constraint in existing table in SQL. 1
a) insert into
b) alter table
c) add into
d) create table
8. Which SQL command is used to change some values in existing rows? 1
a) update
b) insert
c) alter
d) order
9. STRING=“WELCOME” Line1 1
NOTE= “ ” Line2
for S in range[0,8]: Line3
print(STRING[S]) Line4
print(S STRING) Line5
Value = 100
def funvalue():
global Value
Value//=9
print(Value,end=” “)
Value-=10
print(Value,end=” “)
funvalue()
OR
TXT = ["10","20","30","5"]
CNT = 3
TOTAL = 0
for C in [7,5,4,6]:
T = TXT[CNT]
TOTAL = float (T) + C
print (TOTAL)
CNT-=1
25 What do you understand by GROUP BY in SQL? Explain the use of HAVING clause 2
with GROUP BY.
OR
Write the full form of DDL and DML also write any two commands of DML in SQL.
Section-C
26 a) 2+1
Table: GAMES
GCode GameName Number PrizeMoney ScheduleDate
101 Carom Board 2 5000 23-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 Table Tennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 Lawn Tennis 4 25000 19-Mar-2004
Table: PLAYER
PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
SECTION-D
31 Rehaana Medicos Center has set up its new center in Dubai. It has four buildings as 5
shown in the diagram given below:
Accounts Research
Lab
Store Packaging
Unit
Shortest distance between various buildings
Accounts to Research Lab 55 m
Accounts to Store 150 m
Store to Packaging Unit 160 m
Packaging Unit to Research 60 m
Lab
Accounts to Packaging Unit 125 m
Store to Research Lab 180 m
a) Repeater b) Hub/Switch
32 a) Study the following program and select the possible output(s) from the options 2+3
(i) to (iv) following it.
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="%")
(i) 10%40%70%
(ii) 30%40%50%
(iii) 50%60%70%
(iv) 40%50%60%
b) The code given below inserts the following record in the table Student:
Empno – integer
EName – string
Designation – integer
Salary – integer
Bonus - 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 Employee.
The details (Empno, EName, Designation, Salary and Bonus) 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
Employee.
Statement 3- to add the record permanently in the database
35 Arjun of class 12 is writing a program to create a CSV file “user.csv” which will 4
contain user name and password for some entries. He has written the following
code. As a programmer, help him to successfully execute the given task.
SECTION A
1
(c) myfile = open(‘c:\test.txt’,’w+’)
(d) myfile = open(‘c:\\test.txt’,’rb’)
7. Which of the following operators can take wild card characters for query condition? 1
(a) BETWEEN
(b) LIKE
(c) IN
(d) NOT
8. In SQL, which of the following will select only one copy of each set of duplicable rows 1
from a table?
(a) SELECT UNIQUE
(b) SELECT DISTINCT
(c) SELECT DIFFERENT
(d) All of these
9. Given tp = (1,2,3,4,5,6). Which of the following two statements will give the same 1
output?
1. print(tp[:-1])
2. print(tp[0:5])
3. print(tp[0:4])
4. print(tp[-4:])
2
(d) 100
15. Which clause is used with “aggregate functions” ? 1
(a) GROUP BY
(b) SELECT
(c) WHERE
(d) Both (a) and (c)
16. To fetch one record from the result set, you may use <cursor>.______ method: 1
(a) fetch()
(b) fetchone()
(c) fetchsingle()
(d) fetchtuple()
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); Binary file is faster than text file, so it is mostly used for storing data. 1
Reasoning (R): Text file stores less characters as compared to the binary file.
18. Assertion (A); A variable is still valid if it is not defined inside the function. The values 1
defined in global scope can be used.
Reasoning (R): Python used LEGB rule to resolve the scope of a variable.
SECTION B
19. Sumit is trying to write a program to find the factorial of a number passed to the 2
function and he has written the following code but it’s not working and producing
errors. Help Sumit to correct this and rewrite the corrected code. Also underline the
corrections made.
3
(b) Write the output of the following code given below:
Marks = {‘Sidhi’:65,’Prakul’:62,’Suchitra’:64,’Prashant’:50}
newMarks = {‘Suchitra’:66,’Arun’:55,’Prashant’:49}
Marks.update(newMarks)
for key,value in Marks.items():
print(key,’scored’,value,’marks in Pre Board’,end= ‘ ‘)
if(value<55):
print(‘and needs imporovement’end=’.’)
print()
22. Explain Referential Integrity in a Relational Database Management System. Why DBMS 2
is better than File System.
23. (a) Write full forms of the following: 2
(i) SMTP
(ii) IMAP
(b) What is MAC address?
24. Predict the output of the Python code given below: 2
def change(A):
S=0
for i in range(len(A)//2):
S+=(A[i]*2)
return S
B = [10,11,12,30,32,34,35,38,40,2]
C = change(B)
print('Output is',C)
OR
Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Add = 0
for C in range(1,6,2):
Times = Times + C
Alpha = Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times,Add,Alpha)
25. What is the difference between CHAR and VARCHAR ? Write 2-3 differences. 2
OR
Differentiate between a Candidate Key and Alternate Key.
SECTION C
26. (a) Consider the following tables CUSTOMER and TRANSACTION: 1+2
Table: CUSTOMER
ACNO NAME GENDER BALANCE
C1 RISHABH M 15000
C2 AAKASH M 12500
C3 INDIRA F 9750
4
Table: TRANSACTIONS
ACNO TDATE AMOUNT TYPE
C1 2022-07-21 1000 DEBIT
C2 2022-08-31 1500 CREDIT
C3 2022-09-15 2000 CREDIT
(b) Write the output of the queries (i) to (iv) based on the tables, ACCOUNT and
TRANSACT given below:
Table: ACCOUNT
ANO ANAME ADDRESS
101 Nirja Singh Bangalore
102 Rohan Gupta Chennai
103 Ali Reza Hyderabad
104 Rishabh Jain Chennai
105 Simran Kaur Chandigarh
Table: TRANSACT
TRNO ANO AMOUNT TYPE DOT
T001 101 2500 Withdraw 2017-12-21
T002 103 3000 Deposit 2017-06-01
T003 102 2000 Withdraw 2017-05-12
T004 103 1000 Deposit 2017-10-22
T005 101 12000 Deposit 2017-11-06
5
Last time he went to Agra,
there was too much crowd, which he did not like.
So this time he decided to visit some hill station.
The function should read the file content and display the output as follows:
OR
For example :
If the content of the file is
ME AND MY FRIENDS
ENSURE SAFETY AND SECURITY OF EVERYONE
Table: TRAINS
TNO TNAME START END
11096 Ahimsa Express Pune Junction Ahmedabad Junction
12015 Ajmer Shatabdi New Delhi Ajmer Junction
1651 Pune Hbj Special Pune Junction Habibganj
13005 Amritsar Mail Howrah Junction Amritsar Junction
12002 Bhopal Shatabdi New Delhi Habibganj
12417 Prayag Raj Express Allahabad Junction New Delhi
Table: PASSANGERS
PNR TNO PNAME GENDER AGE TRAVELDATE
P001 13005 R N AGRAWAL MALE 45 2018-12-25
P002 12015 P TIWARY MALE 28 2018-11-10
P003 12015 S TIWARY FEMALE 22 2018-11-10
P004 12030 S K SAXENA MALE 42 2018-10-12
P005 12030 S SAXENA FEMALE 35 2018-10-12
P006 12030 P SAXENA FEMALE 12 2018-10-12
[“Danish”,80,”Maths”]
[“Hazik”,79,”CS”]
[“Parnik”,95,”Bio”]
[“Danish”,70,”CS”]
[“Sidhi”,99,”CS”]
[“Hazik”,”79”]
[“Sidhi”,”99”]
Stack Empty
OR
Employee ={"Sohan”:20000,”Mohan”:9000,”Rohan”:25000,”Aman”:5000}
The stack should contain
Mohan
Aman
Pediatrics Unit 40
Administrative Office 140
Neurology 50
Orthopedics Unit 80
ADMINSISTRATIVE OFFICE
NEUROLOGY UNIT
(i) Suggest the most suitable location to install the main server of this
institution to get efficient connectivity.
(ii) Suggest the best cable layout for effective network connectivity of the
building having server with all the other buildings.
(iii) Suggest the devices to be installed in each of these buildings for connecting
computers installed within the building out of the following:
• Switch
• Gateway
def myfunction(str1):
rstr1 = ‘’
index = len(str1)
while index>0:
if str1[index-1].isalpha():
rstr1+=str1[index-1]
index = index-1
return rstr1
print(myfunction(‘1234abcd’))
(b)
The code given below updates the record of table EMP by increasing salary by
1000Rs. of all those employees who are getting less than 80000Rs.
empno – integer
empname – string
salary – float
import mysql.connector as ms
db1 = ms.connect(host=’localhost’,user=’root’,passwd=’admin’,database=’abcinfo’)
cur = __________ #Statement 1
sql = ‘UPDATE ____ ________________’ #Statement 2
______ _______ #Statement 3
print(‘Data Updated successfully’)
OR
(a) What possible output(s) is/are expected to be displayed on the screen at the
time of execution of the program from the following code ? Also specify the
maximum and minimum value that can be assigned to the variable R when K
is assigned value as 2.
import random
Signal = [ 'Stop', 'Wait', 'Go' ]
for K in range(2, 0, -1):
R = random.randrange(K)
print (Signal[R], end = ' # ')
9
(b) The code given below inserts the following record in the table employee:
empID – integer
empName – string
salary – float
dept – sting
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is admin
The table exists in a MYSQL database named empdata.
The details (empID, empName, salary and dept) 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
OR
Help her complete the above code as per the instructions given below:
(a) Complete Fill_Line1 so that the required Python library becomes available to
the program.
(b) Complete Fill_Line2A so that the above mentioned binary file is opened for
writing in the file object fout.
Similarly, complete Fill_Line2B, which will open the same binary file for reading
in the file object fin.
(c) Complete Fill_Line3 so that the list created in the code, namely Sqlist is written
in the open file.
(d) Complete Fill_Line4 so that the contents of the open file in the file handle fin
are read in a list namely mylist.
11
KENDRIYA VIDYALAYA SANGATHAN, JAMMU REGION
SAMPLE PAPER SET – 9
CLASS – XII Subject: COMPUTER SCIENCE
Maximum Marks: 70 Time Allotted: 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
(a) h
(b) n
(c) a
(d) Dia
4. Which among the following operators has the highest precedence? 1
a)+
b)%
c)|
d)**
5. Which of the following is not a valid identifier ? 1
a) ABC
b) _num
c) Prints
d)4map
6. To use randint(a,b) which of the following module should be imported ? 1
a)math
b)random
c)CSV
d)randinteger()
1
7. What will be the output when the following code is executed? 1
L= [1,3,5,4,8,9]
print(L[-1:-5])
8. Central computer which is powerful than other computers in the network is called 1
a) Hub
b) Sender
c) Switch
d) Server
9. Method used to force python to write the contents of file buffer on to storage file is 1
a) count()
b) read()
c) flush()
d) True
10. In a range function, which of the following argument is mandatory to pass: 1
a) Start
b) Stop
c) Step
d) All of these
11. Fill in the blank: 1
___________ is the protocol used to send emails to the e-mail server and _________
is the protocol used to download mail to the client computer from the server.
(a) SMTP,POP (b) HTTP,POP (c) FTP,TELNET (d) HTTP,IMAP
12 Which of the following is a DDL command? 1
a) SELECT
b) ALTER
c) INSERT
d) UPDATE
13. Which of the following is not a function / method of csv module in Python? 1
a. read()
b. reader()
c. writer()
d. writerow()
14. Syntax of seek function in Python is myfile.seek(offset, reference_point) where 1
myfile is the file object. What is the default value of reference_point?
a. 0
b. 1
c. 2
d. 3
15. Which of the following character acts as default delimiter in a csv file? 1
a. (colon) :
b. (hyphen) -
c. (comma) ,
d. (vertical line) |
16. Fill in the blank: 1
__________ is the method used in python while interfacing the SQL with Python to
save the changes permanently to the database while inserting or modifying the
records.
(a) save() (b) commit() (c) final() (d) lock()
2
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): When passing a mutable sequence as an argument, function modifies 1
the original copy of the sequence.
Reasoning (R): Function can alter mutable sequences passes to it.
18. Assertion (A): with statement can be used to open a file and should be preferred 1
over other ways to open a file.
Reasoning (R): with statement is a block of statement that makes sure the file is
closed in case of any run-time error and buffer is cleared to avoid data loss.
SECTION B
19. Consider the following code written by a programming student. The student is a 2
beginner and has made few errors in the code. You are required to rewrite the code
after correcting it and underline the corrections.
Def swap(d):
n = {}
values = d.values()
keys = list(d.keys[])
k=0
for i in values
n(i) = keys[k]
k=+1
return n
result = swap({‘a’:1,’b’:2,’c’:3})
print(result)
20. What are cookies in a web browser ? Write one advantage and one disadvantage of 2
enabling cookies in a web browser.
OR
What is the difference between client side and server side scripting?
21. (a) Consider the given Python string declaration: 2
mystring = ‘Programming is Fun’
a,b,c,d = (1,2,3,4)
mytuple = (a,b,c,d)*2+(5**2,)
print(len(mytuple)+2)
22. What do you mean by DDL and DML commands in DBMS? Write examples of each. 2
23. (a) Write the full forms of the following: 2
(i) WLAN
(ii) WWW
(b) What is a hub? What are its types?
24. Predict the output of the following code: 2
3
def my_func(var1=100, var2=200):
var1+=10
var2 = var2 - 10
return var1+var2
print(my_func(50),my_func())
OR
value = 50
def display(N):
global value
value = 25
if N%7==0:
value = value + N
else:
value = value - N
print(value, end="#")
display(20)
print(value)
25. Differentiate between a PRIMARY KEY and UNIQUE constraint in SQL with 2
appropriate example.
OR
What is the difference between WHERE and HAVING clause? Can we use them
together in a query?
SECTION C
26. (a) Consider the following tables STORE and SUPPLIERS: 1+2
Table: STORE
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpner 23 60 8 31-Jun-
Classic 09
2003 Ball Pen 0.25 22 50 25 01-Feb-
10
2002 Gel Pen 21 150 12 24-Feb-
Premium 10
2006 Gel Pen 21 250 20 11-Mar-
Classic 09
2001 Eraser Small 22 220 6 19-Jan-
09
2004 Eraser Big 22 110 8 02-Dec-
09
2009 Ball Pen 0.5 31 180 18 03-Nov-
09
4
Table: SUPPLIERS
Scode Sname
21 Premium Stationers
23 Soft Plastics
22 Tetra Supply
(b) Write the output of the queries (i) to (iv) based on the tables, ITEM and
CUSTOMER given below:
Table: ITEM
I_ID ItemName Manufacturer Price
PC01 Personal ABC 35000
Computer
LC05 Laptop ABC 55000
PC03 Personal XYZ 32000
Computer
PC06 Personal COMP 37000
Computer
LC03 Laptop PQR 57000
Table: CUSTOMER
C_ID CustomerName City I_ID
01 N Roy Delhi LC03
06 H Singh Mumbai PC03
12 R Pandey Delhi PC06
15 C Sarma Delhi LC03
16 K Agarwal Bangalore PC01
5
__________________________________________________________________
INDIA is a famous country all over the world.
Geographically, India is located to the
south of Asia continent. India is a high
population country and well protected
from all directions naturally.
India is a famous country for
its great cultural and traditional
values all across the world.
__________________________________________________________________
The output should be 4
OR
For example :
If the content of the file is
Table: SENDER
SenderID SenderName SenderAddress SenderCity
ND01 R Jain 2, ABC Appts New Delhi
MU02 H Sinha 12, Newtown Mumbai
MU15 S Jha 27/A, Park Street Mumbai
ND50 T Prashad 122-K, SDA New Delhi
Table: RECIPIENT
RecID SenderID RecName RecAddress RecCity
KO05 ND01 R Bajpayee 5, Central Avenue Kolkata
ND08 MU02 S Mahajan 116, A Vihar New Delhi
MU19 ND01 H Singh 2A, Andheri West Mumbai
MU32 MU15 P K Swamy B5, C S Terminus Mumbai
ND48 ND50 S Tripathy 13, B1 D, Mayur Vihar New Delhi
Note : Assuming that the list has even number of values in it.
For example :
If the list Numbers contain
[25,17,19,13,12,15]
Write a program in python to input 5 words and push them one by one into a list
named All.
The program should then use the function PushNV() to create a stack of words in the
list NoVowel so that it stores only those words which do not have any vowels in it,
from the list All.
Thereafter , pop each word from the list NoVowel and display the message
“EmptyStack”
For example:
If the words accepted and pushed into the list All are
[‘DRY’,’LIKE’,’RHYTHM’,’WORK’,’GYM’]
OR
Write the definition of a user defined function Push3_5(N) which accepts a list of
integers in a parameter N and pushes all those integers which are divisible by 3 or
7
divisible by 5 from the list N into a list named Only3_5.
The program should then use the function Push 3_5() to create the stack of the list
Only3_5. Thereafter pop each integer from the list Only3 5 and display the popped
value. When the list is empty, display the message "StackEmpty".
For example:
30 18 6 10 StackEmpty
31. Piccadily Design and Training Institute is setting up its centre in Jodhpur with four 5
specialised units for Design, Media, HR and Training in separate buildings. The
physical distances between these units and the number of computers to be installed
in these units are given as follows.
You as a network expert, have to answer the queries as raised by the administrator
as given in (i) to (iv).
Shortest distances between various locations in metres :
Design Unit 40
Media Unit 50
HR Unit 110
Training Unit 40
8
i) Suggest the most suitable location to install the main server of this institution to
get efficient connectivity.
(ii) Suggest by drawing the best cable layout for effective network connectivity of the
building having server with all the other units.
(iii) Suggest the devices to be installed in each of these buildings for connecting
computers installed within each of the units out of the following :
Modem, Switch, Gateway, Router
(iv) Suggest an efficient as well as economic wired medium to be used within each
unit for connecting computer systems out of the following network cable :
Co-axial Cable, Ethernet Cable, Single Pair Telephone Cable.
(v) Suggest a protocol that shall be needed to provide Video Conferencing solution
between Jodhpur and HQ which is situated in Delhi.
32. (a) Write the output of the code given below: 2+3
def ChangeVal(M,N):
for i in range(N):
if M[i]%5 == 0:
M[i] //= 5
if M[i]%3 == 0:
M[i] //= 3
L=[25,8,75,12]
ChangeVal(L,4)
for i in L :
print(i, end='#')
(b) The code given below is trying to delete the record of table category of
database items that have the name = ‘Stockable’
import mysql.connector as ms
9
db1 =
ms.connect(host=’localhost’,user=’learner’,passwd=’fast’,database=’items’)
cur = _ ____ #Statement 1
sql = ‘DELETE ____ ________________’ #Statement 2
cur.execute(sql)
______ _______ #Statement 3
print(‘Data Updated successfully’)
OR
(a) Find the output of the following code:
Name="PythoN3.1"
R=""
for x in range(len(Name)):
if Name[x].isupper():
R=R+Name[x].lower()
elif Name[x].islower():
R=R+Name[x].upper()
elif Name[x].isdigit():
R=R+Name[x-1]
else:
R=R+"#"
print(R)
(b) The code given below reads the following record from the table named
teacher and displays only those records whose year of retirement is in 2022.
empcode – integer
Name – string
post – integer
dateofretire – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is kvs
The table exists in a MYSQL database named school.
10
functions:
(I) addCsvFile(UserName,Password) – To accept and add the login details of a
user into the CSV file ‘login.csv’. Each record consist of a list with field
elements as [id,pass] to store Username and password respectively.
(II) checkDetails(username,pass) – To check the login details passed to the
finction from the file. If the details are correct the function returns True
otherwise it returns False.
OR
Name the methods used to read and write the data in a binary file.
Write a program in python that defines and calls the following user defined
functions:
(i) insertData() – To accept and add data of a customer and add it to a csv file
‘customerData.csv’. Each record should contain a list consisting
customername,mobileno,dateofPurchase,itempurchased.
(ii) frequency (name) – To accept the name of a customer and search how
many times the customer has purchased any item. The count and return
the number.
SECTION E
34 Consider the following table HOSPITAL. Answer the questions that follows the table:
Table: HOSPITAL
No. Name Age Department Dateofadm Charges Sex
1 Arpit 62 Surgery 21/01/98 3000 M
2 Zarina 22 ENT 12/12/97 2000 F
3 Kareem 32 Orthopaedic 19/02/98 1500 M
4 Arun 12 Surgery 11/01/98 3000 M
5 Zubin 30 ENT 12/01/98 1500 F
6 Ketaki 16 ENT 24/02/98 2000 M
7 Ankita 29 Cardiology 20/02/98 10000 F
8 Zareen 45 Cardiology 14/07/99 1400 F
9 Kushi 19 Gynaecology 20/01/22 1800 F
10 Shilpa 23 Nuclear 19/05/22 2500 F
Medicine
import pickle
_____________________ # Fill_Line 2
________________________ #Fill_Line 4
print(Rstu)
(a) Complete Fill_Line1 so that the mentioned binary file is opened for writing in
fh object using a with statement.
(b) Complete Fill Line2 so that the dictionary Stul's contents are written on the
file opened in step (a).
(c) Complete Fill_Line3 so that the earlier created binary file is opened for
reading in a file object namely fin, using a with statement.
(d) Complete Fill_Line4 so that the contents of open file in fin are read into a
dictionary namely Rstu.
12
KENDRIYA VIDYALAYA SANGATHAN, JAMMU REGION
SAMPLE PAPER SET-10
Class: XII Session SUBJECT : Computer Science(083)
TIME : 3 HOURS MM : 70
General Instructions:
1. This question paper contains five sections, Section A to E
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 marks each.
4. Section B has 07 very Short Answer type question carrying 02 marks each
5. Section C has 05 Short Answer type question carrying 03 marks each.
6. Section D has 03 Long Answer types question 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 in not a valid variable name in python? 1
(i) Peacock (iii) Pea Cock
(ii) Peacock5 (iv) Peacock_
3. If the following code is executed, what will be the output of the following 1
code?
name="IlovemyCountry"
print(name[3:10])
1
5. Select the correct output of the following code
Fp.seek(5,1)
a) Move file pointer five character ahead from the current postion
b)Move file pointer five character ahead from the beginning of a file
c)Move file pointer five character behind from the current postion
d)Move file pointer five character behind ahead from the end of a file
mystring = “Pynative”
stringList = [ “abc”, “Pynative”,”xyz”]
print(stringList[1] == mystring)
print(stringList[1] is mystring)
a) Ture b) Flase C) 25 D) 0
15. Which portion of the URL below records the directory or folder of the 1
desired resource?
https://www.nishantsingh.com/ghagwal/pgt.htm
a) http b) ghagwal c) www.nishantsingh.com d) pgt.htm
Q17 and Q18 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):- Key word arguments are related to function calls. 1
Reasoning(R ):- When you use keyword arguments in funation call, the caller
identifies the arguments by the parameter name.
18 Assertion(A) : The tell method will stores/get the current location of the file 1
pointer.
Reasoning(R): Python seek method returns the current position of the file
read/write pointer with the file.
Section B
19. Mr. Akash has written a code , His code is having errors , Rewrite the correct code 2
and underline the correction s made.
5x=input(“Enter a number”)
If(abs(x)=x):
Print(“You Entered a positive number..”)
Else:
x=x-1
print(“Number made positive:”x)
21 a) If the following code is executed, what will be the output of the following 1
code?
mystr1 = ‘Sequence with labels’
mystr2 = ‘$’
print(mystr2*6+mystr1+mystr2*5)
1
b) What will be the output of the following code snippet?
init_tuple_a =( 'a', '3’)
init_tuple_b = ('sum', '4')
print (init_tuple_a + init_tuple_b)
27 Assume that a text file named TEXT1.TXT already contains some text written 3
into it ,write a function named COPY(),that reads the file TEXT1.TXT and create a
new file named TEXT2.TXT ,which shall contain only those words from the file
TEXT1.TXT which don’t start with an uppercase vowel(i.e. with ‘A’,’E’,’I’,’O’,’U’)
,for example if the file TEXT1.TXT contains
He can appoint any member of the Lok Sabha
then the file TEXT2.TXT shall contain
He can member of the Lok Sabha
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
28 Write the outputs of the SQL queries (i) to (iii) based on the relations VEHICLE 3
and TRAVEL given below:
VCODE VEHICLETYPE PERKM
V01 VOLVO BUS 150
V02 AC DELUX BUS 125
V03 ORDINARY BUS 80
V04 CAR 18
V05 SUV 30
NOTE: PERKM is fright charges per kilometer
Table: TRAVEL
CNO CNAME TRAVELDATE KM VCODE NOP
101 K. Niwal 2015-12-13 200 V01 32
103 Fredrick Sym 2016-03-21 120 V03 45
105 Hitesh Jain 2016-04-23 450 V02 42
102 Ravi Anish 2016-01-13 80 V02 40
107 John Malina 2015-02-10 65 V04 2
104 Sahanubhuti 2016-01-28 90 V05 4
106 Ramesh Jaya 2016-04-06 100 V01 25
NEW DELHI
Head
INDIA Tech
Office
Sales Office
Office
eee
Kolkata
Ahmedabad Coimbat
ore
a) Suggest network type for connecting each of the following set of their offices:
Head Office and Tech Office
Head Office and Coimbatore Office
b) Which device you will suggest to be produced by the company for connecting all the
computers with in each of their offices out of the following device?
i) Switch/Hub ii)Modem iii)Telephone
c) Which of the following communication media, you will suggest to be procured by th
company for connecting their local offices in New Delhi for very effective and fast
communication.
i) Telephone Cable ii) Optical fibre iii) Ethernet cable
d) Suggest a Cable /Wiring layout for connecting the company’s local offices located in
New Delhi . Also, suggest an effective method /technology for connecting the company
‘s regional office at “Kolkata”,”Coimbatore and “Ahmedabad”.
32 Write a function in python, PushEl(element) and MakeEl(element) to add a new 5
element and delete a element from a List of element Description, considering
them to act as push and pop operations of the Stack data structure .
Or
Write a function in Python PUSH(A), where A is a list of numbers. From this list
push all even numbers into a stack implemented by using a list. Display the stack
if it has at least one element, otherwise display appropriate error message
33 Write a function countVowels() in Python, which should read each character of a 5
text file
“myfile.txt”, count the number of vowels and display the count.
Example:If the “myfile.txt” contents are as follows:
This is my first class on Computer Science.
The output of the function should be: Count of vowels in file: 10
Section E
Table: MobileStock
S_Id M_Id M_Qty M_Supplier
S001 MB004 450 New Vision
S002 MB003 250 Praveen Gallery
S003 MB001 300 Classic Mobile Store
S004 MB006 150 A-one-Mobiles
S005 MB003 150 The Mobile
S006 MB006 50 Mobile Centre
i)Display the Mobile company, Mobile Name & Price in descending order of their
manufacturing date.
ii)List the details of mobile whose name starts with s
iii)Display the mobile supplier and quantity of all mobiles except MB003.
iv) Display the name of mobile company having price between 3000 and 5000
v) Display the name of company, supplier and Price by joining the joining the two
tables where price is more than 5000.
35 Pushpa writing a program to create a CSV file “item.csv” which will contain item 5
name, Price and quantity of some entries. He has written the following code. As
a programmer, help him to successfully execute the given task.
import _____________ # Line
def addInCsv(item,price,qty): # to write / add data into the CSV file
f=open(' item.csv','________') # Line
csvFileWriter = csv.writer(f)
csvFileWriter.writerow([item,price,qty])
f.close()
#csv file reading code
defreadFromCsv(): # to read data from CSV file
with open(' item.csv','r') as csvFile:
newFileReader = csv._________(csvFile) # Line
for row in newFileReader:
print (row[0],row[1],row[2])
csvFile.______________ # Line
addInCsv('Note Book',45,100)
addInCsv('Text Book',60,150)
addInCsv('Ball Pen',10,100)
addInCsv('Pencil', 5,200)
readFromCsv() #Line
(a) Name the module he should import in Line 1.
(b) In which mode, Pushpa should open the file to add data into the file
(c) Fill in the blank in Line 3 to read the data from a csv file.
(d) Fill in the blank in Line 4 to close the file.
(e) Write the output he will obtain while executing Line 5.
KENDRIYA VIDYALAYA SANGATHAN, JAMMU REGION
SAMPLE PAPER SET-11
Class: XII Session SUBJECT : Compute Science(083)
TIME : 3 HOURS MM : 70
General Instructions:
SECTION A
1. State True or False 1
The value of the expression 5/(6*(4-2)) and 5/6*(4-2) is the same.
2. Which of the following is the data type of value, returned by input( ) method in 1
Python?
(a ) Boolean (b) String (c) Int (d) Float
3. Given the following dictionaries 1
Dict1={‘Tuple’:’immutable’,’List’:’mutable’,’Dictionary’:’mutable’,’String’:’immu
table’}
Which of the following will delete key:value pair for key=‘Dictionary’ in the
above mentioned dictionary?
a. del Dict1[‘Dictinary’]
b. Dict1[‘Dictionary’].delete( )
c. delete (Dict1.[“Dictionary”])
d. del(Dict1.[‘Dictionary’])
4. Consider the given expression: 1
print(2**5+8//3*7-2)
Which of the following will be correct output if the given expression evaluated?
(a) 44
(b) 34
(c) 42
(d) 36
(A) 0
(B) 2
(C) 1
(D) Error
15 All aggregate function except _________ ignore NULL values in order the 1
produce the output.
(A) AVG( )
(B) COUNT( )
(C) COUNT(*)
(D) TOTAL( )
16 To establish a connection between Python and SQL database, connect() 1
method is used. Identify the correct syntax of connect( ) method from the
followings.
(A) Connect(user=”user name”, passwd=”password”, host=”host name”,
database= “database name”)
(B) Connect(host=”host name”, user=”user name”, password=”password”,
database= “database name”)
(C) Connect(host=”host name”, user=”user name”, passwd=”password”,
database= “database name”)
(D) Connect(host=”host name”, database= “database name”, user=”user
name”, password=”password”)
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 and R is False.
(D) A is False and R is True.
17 Assertion (A) : A function is a block of organized and reusable code that is used 1
to perform a single related action.
Reason (R) : Function provides better modularity for your application and a
high degree of code reusability.
18 Assertion (A) : Text file stores information in ASCII or Unicode characters. 1
Reason (R) : CSV stands for comma separated value. These files are common
file format for transferring and storing data.
SECTION B
19 Anshika has written a code to calculate the factorial value of a number, but her 2
code is having some errors. Rewrite the correct code and underline the
corrections made.
def Factorial(Num)
1=fact
While num=>0:
fact=fact*num
num=-1
print(“Factorial value is =”,fact)
20. Differentiate between Viruses and Worms in context of networking and data 2
communication threats.
OR
Differentiate between Web server and web browser. Write any two popular
web browsers.
21 (A) Given is a Python List declaration : 1
L1=[11,23,16,28,55,37,61,89]
write the output of the code given below :
print(L1[-3:8])
(B) Given is a Python Dictionary : 1
Lib={“Novel”:152,”Magzine”:20,”Newspaper”:10,”Books”:250}
Write Python statement to delete key:value pair for key=”Novels”.
22 What is the difference between UNIQUE and PRIMARY KEY constraints in an 2
RDBMS.
23 (A) Expand the following terms :- 1
(I) FTP (II) GSM
(B) Danish has to share the data among various computers of his two offices 1
branches situated in the same city. Name the type of network which is being
formed in this process.
24 Predict the output of the Python code given below: 2
def Update(str1):
length=len(str1)
temp=""
for i in range(0, length):
if str1[i].islower():
temp=temp+str1[i].upper()
elif str1[i].isupper():
temp=temp+str1[i].lower()
elif str1[i].isdigit():
temp=temp+str(int(str1[i])+1)
else:
temp=temp+'#'
print(temp)
Update("CBSE-2023 Exams")
OR
Mydict={}
Mydict[(1,2,3)]=12
Mydict[(4,5,6)]=20
Mydict[(1,2)]=25
total=0
for i in Mydict:
total=total+Mydict[i]
print(total)
print(Mydict)
25 Define the following terms in context with RDBMS:- 2
(I) Degree (II) Cardinality
OR
Write the full form of DDL and DML. Also write any two examples of DDL and
DML.
SECTION C
DEPARTMENT
Ecode Department
M01 Marketing
S01 Sales
A05 Accounts
H03 HR
What will be the output of the following statement?
SELECT E.Ecode,E.Ename,D. Department FROM EMPLOYEE E,
DEPARTMENT D WHERE E.Ecode = D.Ecode;
(B) Write the output of the queries (i) to (iv) based on the table PRODUCT and
CUSTOMER given below :
PRODUCT
P_ID P_Name Manufacturer Price Discount
TP01 Talcum Powder LAK 40
FW05 Face Wash ABC 45 5
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120 10
FW12 Face Wash XYZ 95
CUSTOMER
C_ID C_Name City P_ID
01 Cosmetic Shop Delhi TP01
02 Total Health Mumbai FW05
03 Live Life Delhi BS01
04 Pretty Woman Delhi SH06
05 Dreams Delhi TP01
i. SELECT P_Name, count(*) FROM Product GROUP BY P_Name;
Example :
If the file contents are as follows:-
OR
Write a method COUNT_WORD()in Python to read lines from a text file
“PLEDGE.TXT” and count and display the occurrences of the word “country” in
the file.
Example :-
If the content of the file are as follows :-
India is my country and all Indians are my brothers and sisters. I love my country
and I am proud of its rich and varied heritage. I shall always strive to be worthy
of it.
I shall give respect to my parents, teachers and elders and treat everyone with
courtesy.
To my country and my people, I pledge my devotion. In their well being and
prosperity alone, lies my happiness.
The COUNT_WORD() function should display the output as :
Total Occurrences of word “country” = 3
28 (A) Write the outputs of the SQL queries (i) to (iv) based on the relations CAR 2+1
and OWNER given below:-
CAR
C_code Carname Make Color Capacity Charges
501 Ignis Suzuki Blue 5 14
503 Saltoz Tata White 5 16
502 Innova Toyota Silver 7 18
509 SX4 Suzuki Black 5 20
510 NIOS Hyundai Grey 5 15
CUSTOMER
C_Id Cname C_code
1001 Vansh Sharma 501
1002 Shivanand 509
1003 Tanish Sharma 503
1004 Palak 502
(i) SELECT COUNT(DISTINCT Make) FROM CAR;
(ii) SELECT MAX(Charges), MIN(Charges) FROM CAR;
(iii) SELECT COUNT(*), Make FROM CAR;
(iv) SELECT Carname FROM CAR WHERE Capacity=7;
(B) Write SQL Command to show the list of all the databases.
(i) What will be the most appropriate block, where RSC should plan to 1
house the server?
(ii) Suggest the cable layout to connect al the buildings in the most 1
appropriate manner for efficient communication.
(iii) What will the best suitable connectivity out of the following to 1
connect the offices in Bangalore with its New York based office.
(a) Infrared (b) Satellite Link (c ) Ethernet Cable
(iv) Suggest the placement of the following devices with justification.
(a) Hub / Switch (b) Repeater 1
(v) Which service / protocol will be most helpful to conduct the live
interactions of Experts from New York to Human Resource Block. 1
32 (A) Write the output of the Python code given below : 2+3
a=10
def fun(x=10,y=5):
global a
a=y+x-3
print(a,end="@")
i=20
j=4
fun(i,j)
fun(y=10,x=5)
(B) The code given below inserts th following record in the table Employee:
ECode – Integer
EName – String
Deptt – String
Salary – Float
Note the following to establish connectivity between Python and MYSQL :
Username is admin
Password is Hello123
Database is KVS
The Department of the employee will be entered by the user in order
to get the list of employees in the department.
Write the following missing statements to complete the code:
Statement 1 – To form the cursor object.
Statement 2 – To execute th command that searches for the employee code in
the table Employee.
Statement 3 – To show all the records returned by the query.
import mysql.connector as con
def Emp_data():
mycon=con.connect(host=”localhost”,user=”admin”,passwd=”Hello123
”,database=”KVS”)
mycursor=__________________________ # Statement 1
Dept=input(“Enter Department name to be searched for =”)
Qry_Str=”Select * from Employee where deptt=”+Dept
_______________________________ # Statement 2
Mydata=__________________________ # Statement 3
for row in Mydata:
print(row)
mycon.close()
OR
(A) Predict the output of the code given below:
x=[1,2,3]
ctr=0
while ctr<len(x):
print(x[ctr]*’#’
for y in x:
print(y*’$ ‘)
ctr+=1
(B) The code give below reads the following record from the table named
“SALES” and update those records who have Sale>50000 in order to
provide commission 4% of Sale amount.
Scode – integer
Sname- String
Saleamt – Float
Commission – Float
Note the following to establish conectivity between Python and MySQL :
Username is root
Password is Scott
Database Name : Company
Write the following missing statements to complete the code :
Statement 1 – to form the cursor object
Statement 2 – to execute the query to update the commission column as 4% of
Saleamount for those records only who have Sale>50000.
Statement 3 – to add the data parmanently in the database.
OR
34. Karan creates a table GAMES with a set of records to store the details of Games 1+1+2
like Name of Game, Type of Game, Prize Money etc. as given below. After
creation of the table, he has entered some records as shown below :
GCode GName Type PrizeMoney ScheduleDate
101 Badminton Outdoor 15000 10-Oct-2021
102 Chess Indoor 20000 01-JUL-2020
103 Table Tennis Indoor 10000 01-Mar-2022
104 Carom Board Indoor 8000 15-AUG-2023
105 Cricket Outdoor 25000 01-DEC-2022
SECTION-A
Q.1 Which of the following are in-valid operators in Python? 1
(A) += (B) ^ (C) =+ (D) &&
Q.2 Which function is used to remove the given characters from trailing end i.e. right end of a string? 1
(A) strip( ) (B) remove( ) (C) lstrip( ) (D) rstrip( )
Q.3 Predict the output of following python code. 1
SS="PYTHON"
print( SS[:3:])
(A) THON (B) PYT (C) PYTH (D) HON
Q.4 A Python List is declared as Stud_Name = ['Aditya', 'aman', 'Aditi','abhay'] 1
What will be the value of min(Stud_Name)?
(A) abhay (B) Aditya (C) Aditi (D) aman
Q.5 Choose the correct output of following code: 1
Tup=(100)
print(Tup*3)
(A) (300,) (B) (100,100,100) (C) Syntax Error (D) 300
Q.6 In a stack, if a user tries to remove an element from empty stack it is called _________ 1
(A) Underflow (B) Empty (C) Overflow (D) Blank
Q.7 Which method is used for object serialization in Python? 1
(A) Pickling (B) Un-pickling (C) Merging (D) None of the above
Q.8 Which types of arguments/parameters supports by Python? 1
PS-SP-QP-XII-CS-22-23 1 | Page
(A) Positional Argument (B) Default Arguments
(C) Keyword (or named) Arguments (D) All of Above
Q.9 If a function in python does not have a return statement, which of the following does the function 1
return?
(A) int (B) float (C) None (D) Null
Q.10 A________is a set of rules that governs data communication. 1
(A) Forum (B) Protocol (C) Standard (D) None of the above
Q.11 Select correct collection of DDL Command? 1
(A) CREATE, DELETE, ALTER, MODIFY (B) CREATE, DROP, ALTER, UPDATE
(C) CREATE, DROP, ALTER, MODIFY (D) CREATE, DELETE, ALTER, UPDATE
Q.12 Which statement is used to display the city names without repetition from table Exam? 1
(A) SELECT UNIQUE(city) FROM Exam; (B) SELECT DISTINCT(city) FROM Exam;
(C) SELECT PRIMARY(city) FROM Exam; (D) All the above
Q.13 Ronak want to show the list of movies which name end with ‘No-1’. Select the correct query if table 1
is MOVIE and field attribute is Movie_Name.
(A) SELECT Movie_Name FROM MOVIE WHERE Movie_Name = ‘%No-1’;
(B) SELECT Movie_Name FROM MOVIE WHERE Movie_Name = ‘No-1%’;
(C) SELECT Movie_Name FROM MOVIE WHERE Movie_Name LIKE ‘%No-1’;
(D) SELECT Movie_Name FROM MOVIE WHERE Movie_Name LIKE ‘No-1%’;
Q.14 Which Constraint not allow to enter repeated values in the table? 1
(A) PRIMARY KEY (B) UNIQUE (C) BOTH A and B (D) None of
above
Q.15 COMMIT command is belongs to 1
(A) DDL Command (B) DML Command (C) TCL Command (D) None of the above
Q.16 Which function is used to create a cursor in Python – SQL connectivity? 1
(A) fetch() function (B) execute() function (C) connect() function (D) curse()
function
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
Q.17 Assertion (A):- In stack, program should check for Underflow condition, before executing the pop 1
operation.
Reasoning (R):- In stack, underflow mean there is no element available in the stack or stack is an
empty stack.
Q.18 Assertion (A):- The readlines() method in python reads all lines from a text file. 1
Reasoning (R):- The readlines() method returns the tuple of lines(string).
SECTION-B
Q.19 A student has written a code to print a pattern of even numbers with equal intervals. His code is 2
having errors. Rewrite the correct code and underline the corrections made.
def pattern(start=0, end, interval):
PS-SP-QP-XII-CS-22-23 2 | Page
for n in range(start: end, interval):
if(n%2==1):
print(n)
else
pass
x=int(input("Enter Start Number: "))
y=int(input("Enter End Number: "))
z=int(input("Enter Interval: "))
pattern(x,y,z)
Q.20 (A) line="T-20 Cricket World Cup 2022" 2
x=line[::-1]
print(a[0:4:1][::-1])
(B)
India={"Animal":"Tiger","Bird":"Peacock","Flag":"Tri-Color"}
India["Capital"]="New Delhi"
print(India.values())
Q.21 Find and write the output of the following python code: 2
def Alter(P=15,Q=10):
P=P*Q
Q=P/Q
print(P,"#",Q)
return Q
A=100
B=200
A=Alter(A,B)
print(A,"$",B)
B=Alter(B)
print(A,"$",B)
Q.22 Write full form on given abbreviation 2
(i) URL
(ii) SMTP
Q.23 Explain the difference between webpage and website with examples of each. 2
OR
What is the difference between Packet Switching and Circuit Switching?
Q.24 What is the role of connect() and rowcount() methods in python. 2
Q.25 What is the importance of UNIQUE constraints in a table? Give a suitable example. 2
OR
Explain the terms degree and cardinality with example in reference to table.
SECTION-C 2
Q.26 Write a method COUNT_WORDS() in Python to read text file ‘STUDENT.TXT’ and display the
total number of Words in the file which start with ‘S’ and end with ‘R’.
your output should shown like given below:
No. of word found: …….
Q.27 Write definition of a function How_Many(List, elm) to count and display number of times the value 3
of elem is present in the List. (Note: don’t use the count() function)
For example :
If the Data contains [205,240,304,205,402,205,104,102] and elem contains 205
The function should display 205 found 3 Times
PS-SP-QP-XII-CS-22-23 3 | Page
Q.28 Write PUSH_CITY(cities) and POP_CITY(cities) methods/functions in Python to add new city name 3
and delete city name from a List of cities, considering them to act as push and pop operations of the
Stack data structure.
OR
Write a function in Python PUSH_VAL(val), where val is a list of numbers. From this list push all
odd numbers into a stack implemented by using a list. Display the stack if it has at least one element,
otherwise display appropriate messages.
Q.29 Consider the following tables SCHOOL and ADMIN and answer this question :
Give the output the following SQL queries :
PS-SP-QP-XII-CS-22-23 4 | Page
Q.30 Write a output for SQL queries (i) to (iii), which are based on the table: SCHOOL and ADMIN given below: 3
TABLE: SCHOOL
PS-SP-QP-XII-CS-22-23 5 | Page
Distances between various wings are given below:
Wing A to Wing S 100m
Wing A to Wing J 200m
Wing A to Wing H 400m
Wing S to Wing J 300m
Wing S to Wing H 100m
Wing J to Wing H 450m
Number of Computers installed at various wings are as follows:
Wings Number of Computers
Wing A 20
Wing S 150
Wing J 50
Wing H 25
(a) Suggest the best-wired medium and mention the topology or layout to connect various
wings of Excel Public School, Coimbatore.
(b) Name the most suitable wing to house the server. Justify your answer.
(d) Suggest a device that can provide wireless Internet access to all smartphone/laptop users
in the campus of Excel Public School, Coimbatore.
(e) What should be the Network Topology among all blocks of the organization :
(a) LAN (B) MAN (c) WAN (IV) Any of these
Q.32 (A). Write the output of following Python code. 2
def change(): +
Str1="WORLD-CUP2022" 3
Str2=""
I=0
while I<len(Str1):
if Str1[I]>="A" and Str1[I]<="M":
Str2=Str2+Str1[I+1]
elif Str1[I]>="0" and Str1[I]<="9":
Str2=Str2+ (Str1[I-1])
else:
Str2=Str2+"*"
I=I+1
print (Str2)
change():
PS-SP-QP-XII-CS-22-23 6 | Page
(B). The code given below extract the following record in from the table Emp whose salary is more
than Rs. 50000:
EmpNo – integer
EmpName – string
Age– integer
Salary – 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 BIG_COMPANY.
∙ The details (EmpNo, EmpName, EmpAge and EmpSalary) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – To create the cursor object
Statement 2 – To execute the command that extract the records of those employees whose salary is
greater than Rs. 50000.
Statement 3 -- To store records from cursor to an object named EmpRecord.
import mysql.connector as cntr
def Emp_Big_Company():
con=cntr.connect(
host="localhost",
user="root",
password="tiger",
database="big_company")
EmpCursor=________________________________ # Statement 1
print("Display Employee whose salary is more than Rs. 50000:")
__________________________________________ # Statement 2
EmpRecord=______________________________________ #Statement 3
for record in EmpRecord:
print(record)
Q.33 (A) Write any two difference between text file and binary file?
(B) Write a Program in Python that defines and calls the following user defined functions:
Add_Book():
To accept data of new book and add to ‘library.csv’ file. The record of book consists
book_id, book_name and book_price in form of python list.
Show_Book():
To read the records of books from ‘library.csv’ file and display the record of books which
price is more than Rs. 500.
SECTION-E
Q.34 Lovepreet is a senior clerk in a MNC. He creates a table salary with a set of records to keep ready for 4
tax calculation. After creation of the table, he has entered data of 5 employees in the table.
Add_New_Product()
Show_Product()
PS-SP-QP-XII-CS-22-23 8 | Page
KENDRIYA VIDYALAYA SANGATHAN, JAMMU REGION
SAMPLE PAPER SET 13
CLASS – XII SUBJECT: Computer Science-083
Total Time- 3 Hours Total Marks- 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 Q35 against part c
only.
8. All programming questions are to be answered using Python Language only.
SECTION-A
1. Name the Python library module needed to be imported to invoke following functions: 1
a. floor ( )
b. randomint ( )
2. To use function of any module, we have to use ____________ (command) before the use 1
of function of a module
3. Identify the key and values from the dictionary given below? 1
a. D = {“Rohan”:{“Manager”:427, “SBI”, 05884 } }
4. Which of the following is/are not assignment operator? 1
a) **= b) /= c) == d) %=
5. Find the output of the code: 1
num = 7
def func ( ) :
num = 27
print(num)
6. Which statement is used to retrieve the current position within the file: 1
a. fp.seek( ) b. fp.tell( ) c. fp.loc d. fp.pos
7. Clause used in select statement to collect data across multiple records and group the 1
results by one or more columns:
a. order by
b. group by
c. having
d. where
8. Which keyword eliminates redundant data from a SQL query result? 1
9. What does the following code print to console? 1
if True:
print(50)
else:
print(100)
a. True b. False c.50 d.100
10. Fill in the blank: 1
No. of rows in a relation is called ………………….. .
(a) Degree b. Domain c. Cardinality d. Attributes
11. Which of the following is not a correct Python statement to open a test file “Students.txt” 1
to write content into it :
a. f= open(“Students.txt”, ‘a’)
b. f= open(“Students.txt”, ‘w’)
c. f= open(“Students.txt”, ‘w+’)
d. f= open(“Students.txt”, ‘A’)
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): Dictionaries are enclosed by curly braces { } 1
Reason(R): The key-value pairs are separated by commas ( , )
18. Assertion(A): The random module is a built-in module to generate the pseudo-random 1
variables.
Reason(R): The randrange() function is used to generate a random number between the
specified range in its parameter.
SECTION-B
19. Yuvika has to complete her computer science assignment of demonstrating the use of if-else 2
statement. The code has some error(s). Rewrite the correct code underlining all the
corrections made.
marks = int(“enter marks”)
temperature = input(“enter temperature”)
if marks < 80 and temperature >= 40
print(“Not Good”)
else
print(“OK”)
20. Write a short note on web hosting. 2
OR
What is work of TCP / IP explain.
21. Write the output after evaluating he following expressions: 1
a) k= 7 + 3 **2 * 5 // 8 – 3
print(k)
b) m= (8>9 and 12>3 or not 6>8)
print(m) 1
22. What do you understand by table constraint in a table? Give a suitable example in support 2
of your answer.
23. Expand the following terms: 2
a. PAN b. HTML c. URL d. POP
24. Predict the output of the Python code given below: 2
def func(n1 = 1, n2= 2):
n1= n1 * n2
n2= n2 + 2
print(n1, n2)
func( )
func(2,3)
OR
26. (a) Observe the following table and answer the question accordingly 1+2
Table:Product
Pno Name Qty PurchaseDate
101 Pen 102 12-12-2011
102 Pencil 201 21-02-2013
103 Eraser 90 09-08-2010
109 Sharpener 90 31-08-2012
113 Clips 900 12-12-2011
What is the degree and cardinality of the above table?
(b) Write the output of the queries (i) to (iv) based on the table, STUDENT given below:
S.NO NAME STIPEND SUBJECT AVERAGE DIV
1 KARAN 400 PHYSICS 68 I
2 DIWAKAR 450 COMP Sc 68 I
3 DIVYA 300 CHEMISTRY 62 I
4 REKHA 350 PHYSICS 63 I
5 ARJUN 500 MATHS 70 I
6 SABINA 400 CHEMISTRY 55 II
7 JOHN 250 PHYSICS 64 I
8 ROBERT 450 MATHS 68 I
9 RUBINA 500 COMP Sc 62 I
10 VIKAS 400 MATHS 57 II
(i) Select MIN(AVERAGE) from STUDENT where SUBJECT=”PHYSICS”;
(ii) Select SUM(STIPEND) from STUDENT WHERE div=’II’;
(iii) Select AVG(STIPEND) from STUDENT where AVERAGE>=65;
(iv) Select COUNT(distinct SUBJECT) from STUDENT;
Write a function count( ) in Python that counts the number of “the” word present in a text
file “STORY.TXT”.
If the “STORY.TXT” contents are as follows:
This is the book I have purchased. Cost of the book was Rs. 320.
Then the output will be : 2
28. (a)Write the outputs of the SQL queries (i) to (iii) based on the tablesEmp: 3
29. Write definition of a Method MSEARCH(STATES) to display all the state names from a 3
list of STATES, which are starting with alphabet M.
For example:
If the list STATES contains[“MP’,”UP”,”MH”,”DL”,”MZ”,”WB”]
The following should get displayed
MP
MH
MZ
30. Write a function in Python push(S,item), where S is stack and item is element to be 3
inserted in the stack.
OR
Write a function in Python pop(S), where S is a stack implemented by a list of items. The
function returns the value deleted from the stack.
SECTION-D
31. A software organization has to set up its new data center in Chennai. It has four blocks of
buildings – A, B, C and D.
32. (a) Find and write the output of the following python code: 2+3
def change(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+'is'
print(m)
change('kv@onTHEtop')
(b) The given program is used to connect with MySQL abd show the name of the all the
record from the table “stmaster” from the database “oraclenk”. You are required to
complete the statements so that the code can be executed properly.
import .connector pymysql
dbcon=pymysql. (host=”localhost”, user=”root”,
=”kvs@1234”)
if dbcon.isconnected()==False
print(“Error in establishing connection:”)
cur=dbcon. ()
OR
(a) Write output of the following code:
def func(a):
s=m=n=0
for i in (0,a):
if i%2==0:
s=s+i
elif i%5==0:
m=m+i
else:
n=n+i
print(s,m,n)
func(15)
(b) Avni is trying to connect Python with MySQL for her project. Help her to write the
python statement on the following:-
(i) Name the library, which should be imported to connect MySQL with Python.
(ii) Name the function, used to run SQL query in Python.
(iii) Write Python statement of connect function having the arguments values as:
Host name :192.168.1.101
User : root
Password: Admin
Database : KVS
33. Divyanshi writing a program to create a csv file “a.csv” which contain user id and 5
name of the beneficiary. She has written the following code. As a programmer help
her to successfully execute the program.
import #Line 1
with open('d:\\a.csv','w') as newFile:
newFileWriter = csv.writer(newFile)
newFileWriter.writerow(['user_id','beneficiary'])
newFileWriter. ([1,'xyz']) #Line2
newFile.close()
35. (a) What is the difference between 'w' and 'a' modes? 1+1+2
Anshuman is a Python learner, who has assigned a task to write python
Codes to perform the following operations on binary files. Help him in writing codes to
perform following tasks (b) & (c):
(b) Write a statement to open a binary file named SCHOOL.DAT
in read mode. The fileSCHOOL.DAT is placed in D: drive.
(c) 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 30000 (both
values inclusive).
KENDRIYA VIDYALAYA SANGATHAN, JAMMU REGION
SAMPLE PAPER SET 14
CLASS – XII SUBJECT: Computer Science-083
Total Time- 3 Hours Total Marks- 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 Q35 against part c only.
8. All programming questions are to be answered using Python Language only.
7 A tuple is declared as T = (20,5,16,29,83) What will be the problem with the code 1
T[1]=100
8 Name the built-in mathematical function / method that is used to return greatest 1
common divisor of x and y.
9 Identify the data type of X: 1
X = tuple(list( (1,2,3,4,5) ) )
11 Sunita executes following two statements but got the variation in result 6 and 5 why? 1
(i) select count(*) from user ;
(ii) select count(name) from user ;
13 Write a command to add new column marks in table ‘student’ data type int. 1
16 Patterns in SQL are described using two special wild card characters such
as ………………………. And …………………
17 Assertion (A): writerow( ) function helps us to write multiple rows in a csv file at a 1
time.
Reason (R) : Writing one row at a time in a csv file is not possible, we must write
multiple rows at a time.
18 Assertion (A) : With statement can be used to open any file, be it csv file or 1
binary file and while using with statement to open any file there is no need to close the
file.
Reason (R) : With statement groups all the statements related to file handling and
makes sure to close the file implicitly. It closes the file even when any error occurs
during the execution of statements in a with statement.
Attempt any 4 sub parts from each question. Each question carries 1 mark
19 A school KV is considering to maintain their eligible students’ for scholarship’s data using SQL 4
to store the data. As a database administer, Abhay has decided that:
• Name of the database - star
• Name of the table - student
• The attributes of student table as follows:
No. - numeric
Name – character of size 20
Stipend - numeric
Stream – character of size 20
AvgMark – numeric
Grade – character of size 1
Class – character of size 3
Table ‘student’
No. Name Stipend Stream Avgmarks Grade Class
1 Karan 400.00 Medical 78.5 B 12B
2 Divakar 450.00 Commerce 89.2 A 11C
3 Divya 300.00 Commerce 68.6 C 12C
4 Arun 350.00 Humanities 73.1 B 12C
5 Sabina 500.00 Nonmedical 90.6 A 11A
6 John 400.00 Medical 75.4 B 12B
7 Robert 250.00 Humanities 64.4 C 11A
8 Rubina 450.00 Nonmedical 88.5 A 12A
9 Vikas 500.00 Nonmedical 92.0 A 12A
10 Mohan 300.00 Commerce 67.5 C 12C
(b) In which mode, Ranjan should open the file to add data into the file.
(c) Fill in the blank in Line 3 to read the data from a csv file.
a) 6 * 3 + 4**2 // 5 – 8
What is scope of a variable in python and write basic scopes of variables in Python
23 Rewrite the following code in python after removing all syntax errors. Underline each 2
correction done in the code:
Def func(a):
for i in (0,a):
if i%2 =0:
s=s+1
else if i%5= =0
m=m+2
else:
n=n+i
print(s,m,n)
func(15)
24 What possible outputs(s) are expected to be displayed on screen at the time of execution of 2
the program from the following code. Select which option/s is/are correct import random
print(random.randint(15,25) , end=' ')
print((100) + random.randint(15,25) , end = ' ' )
print((100) -random.randint(15,25) , end = ' ' )
print((100) *random.randint(15,25) )
(i) 15 122 84 2500 (ii) 21 120 76 1500
(iii) 105 107 105 1800 (iv) 110 105 105 1900
OR
Predict the output of the following code.
def swap(P ,Q):
P,Q=Q,P
print( P,"#",Q)
return (P)
R=100
S=200
R=swap(R,S)
print(R,"#",S)
26 Write the steps to perform an Insert query in database connectivity application. Table 2
‘student’ values are rollno, name, age (1,’AMIT’,22)
27 Define: 2
1. Repeater 2. Router
28 Differentiate between web server and web browser. Write name of any two browsers. 2
29 Write a function listchange(Arr)in Python, which accepts a list Arr of numbers, the function 3
will replace the even number by value 10 and multiply odd number by 5. Sample Input Data
of the list is:
a=[10,20,23,45]
listchange(a,4)
output : [10, 10, 115, 225]
30 Write a Python program to find the number of lines in a text file ‘abc.txt’. 3
OR
Write a Python program to count the word “if” in a text file abc.txt’.
31 Write the outputs of the SQL queries (i) to (iii) based on the relations Client and Product given 3
below:
Client:
C_ID ClientName City P_ID
01 Cosmetic Shop Delhi TP01
02 Total Health Mumbai FW05
03 Live Life Delhi BS01
04 Pretty Woman Delhi SH06
05 Dreams Delhi TP01
Products:
P_ID ProductName Manufacturer Price Discount
TP01 Talcum LAK 40
Powder
FW05 Face Wash ABC 45 5
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120 10
FW06 Face Wash XYZ 95
RollNo – integer
Name – string
Clas – integer
Marks – integer
35 My Pace University is setting up its academic blocks at Naya Raipur and is planning to set up a 5
network. The University has 3 academic blocks and one Human Resource Center as shown in
the diagram below:
function countrec() in Python that would read contents of the file “STUDENT.DAT” and
display the details of those students whose percentage is above 75. Also display number of
OR
A binary file “Stu.dat” has structure (rollno, name, marks). (i) (ii)
I) Write a function in Python add_record() to input data for a record and add to
Stu.dat.
II) Write a function in python Search record() to search a record from binary file
*****
KENDRIYA VIDYALAYA SANGATHAN, JAMMU REGION
SAMPLE PAPER SET 15
CLASS – XII SUBJECT: Computer Science-083
Total Time- 3 Hours Total Marks- 70
General Instructions:
1. This question paper contains five sections – A to E
2. All questions are compulsory
3. Section A, consists of 18 questions carrying 1 marks 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 c part
only.
8. All programming questions are to be answered using Python Language only`
Section-A
(Each question carries 1 mark from question no. 1 to 16)
Q. NO. QUESTION MAR
KS
1 Which of the following is an invalid variable? 1
(a) hello_world_2
(b) 2_hello_world
(c) day_two
(d) _2
2 What data type is the object below? 1
L=1, 'hello',23.5
(a) List
(b) dictionary
(c) tuple
(d) array
(Assertion Reasoning type question - Each question carries 1 marks from question no.
17 to 18)
Q18: Assertion(A): To remove the middle element 3 from the list L= [1,2,3,4,5] the statement 1
L.remove (3) can be used.
Reason(R): The function remove will delete the element 4 in the list as it is placed on the
index no 3.
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true, but R is not the correct explanation of A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Section-B
(Very short answer question -Each question carries 2 marks from question no. 19 to 26)
32 Which functions can be used as the group functions? What is the use of GROUP BY 3
clause? How are they useful?
Section-D
(Long answer -Each question carries 5 marks from question no. 33 to 34)
33 Write a program to get student data (rollno., name and marks) from user until user 5
wants to add data. Then search for records with roll no 12 or 14. If found display the
records else display an appropriate message.
34 (a) Give one advantage and one disadvantage of optical fibre cable. 5
(b) Differentiate between Tree and Bus topologies of network.
(c) What do email and FTP mean?
(d) Differentiate between repeater and bridge.
(e) Give full form of NFS and FTP.
Section-E
(Case –Study Questions -Each question carries 4 marks from question no. 35 to 36)
35 Rohit, a student of class 12, is learning CSV File Module in Python. During examination, 4
he has been assigned an incomplete python code (shown below) to create a CSV File
'Student.csv' (content shown below). Help him in completing the code which creates the
desired CSV File. Do any 4 out of 5.
CSV File
1,AKSHAY,XII,A
2,ABHISHEK,XII,A
3,ARVIND,XII,A
4,RAVI,XII,A
5,ASHISH,XII,A
Incomplete Code
import _____ #Statement-1
fh = open(_____, _____, newline='') #Statement-2
stuwriter = csv._____ #Statement-3
data = [ ]
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION']
data.append(header)
for i in range(5):
roll_no = int(input("Enter Roll Number : "))
name = input("Enter Name : ")
Class = input("Enter Class : ")
section = input("Enter Section : ")
rec = [ _____ ]#Statement-4
data.append(_____) #Statement-5
stuwriter. _____ (data) #Statement-6
fh.close()
(i) Identify the suitable code for blank space in the line marked as Statement-1.
(ii) Identify the missing code for blank space in line marked as Statement-2.
(iii) Write the function name (with argument) that should be used in the blank space of
line marked as Statement-3. OR Identify the suitable code for blank space in line marked
as Statement-4.
(iv) Identify the suitable code for blank space in the line marked as Statement-5
36 Write SQL commands for the following queries (i) to (iv) based on the relations Shoppe 4
and Accessories given below:
(i)to display name and price of all the accessories in descending order of their price.
(ii)to display id and sname of all shoppe located in nehru place.
(iii)to display minimum and maximum price of each name of accessories.
(iv) to display name, price of all accessories and their respective sname where they
are available.