You are on page 1of 295

Page 1 NODIA Sample Paper 1 Computer Science Class 12

Sample Paper 1
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A
1. The output of the code will be :
s=“Wonders of World”
print(s.count(‘O’) + s.index(‘o’))
(a) 3 (b) 4
(c) 2 (d) 1

2. The constraint that is used to provide a condition on a field to take specific values only is :
(a) NULL (b) PRIMARY KEY
(c) CHECK (d) NOT NULL

3. Which of the following are random number generators ?


(a) randint() (b) randrange()
(c) random() (d) All of these

4. Which of the following are sequence of character data?


(a) Lists (b) Tuples
(c) Strings (d) Dictionaries

5. A device that connects two dissimilar networks is


(a) modem (b) repeater
(c) bridge (d) gateway

6. In which file, no delimiters are used for line and no translations occur?
(a) Text file (b) Binary file
(c) CSV file (d) None of these

7. State True or False


“Multiple elements can be added at the end of list by the append method”.

8. These operators are used to make a decision on two conditions.


(a) Logical (b) Arithmetic
(c) Relational (d) Assignment
9. In files, there is a key associated with each record which is used to differentiate among different records. For every
file, there is atleast one set of keys that is unique. Such a key is called
(a) unique key (b) prime attribute
(c) index key (d) primary key

10. a = 1.0
b = 1.0
a is b # Line 1
Output of Line 1 will be
(a) False (b) True
(c) 1.0 (d) 0.0

11. Which of the following is a correct syntax to add a column in SQL command?
(a) ALTER TABLE table_name ADD column_name data_type;
(b) ALTER TABLE ADD column_name data_type;
(c) ALTER table_name ADD column_name data_type;
(d) None of the above

12. In complex number a + ib, a represents as


(a) real part (b) imaginary part
(c) special part (d) None of these

13. a = 6
b = 5.5
sum = a+b
print(sum)
print(type (sum))
(a) 11.5 (b) 10.5
<class ‘float’> <class ‘float’>
(c) None (d) None of these
<class ‘int’>

14. A column storing Name of a department in a table Emp will be of type


(a) int (b) date
(c) float (d) varchar

15. The........keyword sorts the records in ascending order by default.


(a) LIKE (b) UPDATE
(c) ORDER (d) ORDER BY

16. .........method takes a string and writes it in the file.


(a) writelines() (b) write()
(c) writerow() (d) writer()
Directions : (Q.Nos.-17 and 18) are Assertion and Reason based Questions.

17. Assertion (A) Built-in functions are predefined in the system and can be directly used in any program.
Reason (R) id( ) and type( ) are built-in functions in Python.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.

18. Assertion (A) The CSV files are like TEXT files and are comma separated value files.
Reason (R) The data stored in CSV files are separated by comma by default. Although the delimiter can be changed.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.

Section - B
19. Riya was asked to accept a list of even numbers ,but she did not put the relevant condition while accepting the list
of numbers. She wrote a user defined function odd to even (L) that accepts the list L as an argument and converts
all the odd numbers into even by multiplying them by 2.
def oddtoeven (L)
for i in range (size(L)):
if (L[i]%2! == 0)
L[i]= L[1] ** 2
print (L)
There are some errors in the code . Rewrite the correct code.

20. How are E-mail and chat applications different?


 o
How are LAN and MAN different?

21. Observe the code and write the output


(a) ‘arihant publication’.
count(‘hant’, 0, 10)
(b) dic = {}
dic [(1, 2, 4)] = 8
dic [(4, 2, 1)] = 10
dic [1, 2)] = 24
sum = 0
for i in dic :
sum = sum + dic[i]
print (sum)
22. Write about the terms degree and cardinality of a table.

23. (a) Write the full forms of


(i) URL
(ii) VoIP
(b) Write the use of SMTP.

24. Find the output of following code.


dic = {“Nitin” : (21, “NIIT”), “Ankit” : (15, “NIIT”)}
print(“The original dictionary : ”, str(dic))
result= [(key, i, j) for key, (i, j) in dic.items()]
print(“The list after conversion : ”, str(result))
 o
What output will be generate when the following Python code is executed?
def ChangeList ():
l =[]
l1=[]
l2=[]
for i in range(1, 10):
l.append(i)
for i in range(10, 1, –2):
l1.append(i)
for i in range(len (l1)):
l2.append(l1[i] + l[i])
l2.append (len(l)– len(l1))
print(l2)
ChangeList()

25. Differentiate between DROP and DELETE commands of SQL.


 o
Identify any two DML commands from the following and also explain.
ALTER , INSERT , UPDATE , DROP , CREATE

Section-C

26. (a) Consider the following tables - STUDENT and STREAM :


TABLE: STUDENT
SCODE NAME AGE STRCDE POINTS GRADE
101 Amit 16 1 6 NULL
102 Arjun 13 3 4 NULL
103 Zaheer 14 2 1 NULL

TABLE: STREAM
STRCDE STRNAME
1 SCIENCE+COMP
2 SCIENCE+ BIO
3 SCIENCE+ECO
4 COMMERCE+MATHS
What will be the ouput of the following statement?
SELECT NAME, STRNAME FROM STUDENT S, STREAM ST WHERE S.STRCDE=ST.STRCDE;

(b) Write the output for SQL queries (i) to (iv), which are based on the table ITEMS.
TABLE: ITEMS
Code IName Qty Price Company TCode
1001 DIGITAL PAD 12i 120 11000 XENITA T01
1006 LED SCREEN 40 70 38000 SANTORA T02
1004 CAR GPS SYSTEM 50 2150 GEOKNOW T01
1003 DIGITAL CAMERA 12X 160 8000 DIGICLICK T02

1005 PEN DRIVE 32 GB 600 1200 STOREHOME T03


(i) SELECT MAX(Price), MIN(Price) FROM ITEMS;
(ii) SELECT Price * Qty AS AMOUNT
FROM ITEMS WHERE Code=1004;
(iii) SELECT DISTINCT TCode FROM ITEMS;
(iv) SELECT MAX(Company) FROM ITEMS WHERE Price > 7000;

27. Write a function countEU() in Python, which should read each character of a text file. IMP.TXT should count and
display the occurrence of alphabets E and U (including small cases e and u too).
e.g. If the file content is as follows :
Pinaky has gone to his friend’s house.
His friend’s name is Ravya. Her house is 12 km from Pinaky’s house.
The countEU() function should display the output as
E:8
U:3
 o
Write a Python program to find the longest word in file “status.txt”. If contents of status.txt are Welcome to your one-
step solutions for all your study, practice and assessment need for various competitive and recruitment examinations
and school segment. We have been working tirelessly for over a decade to make sure that you have best in class
study resources because you deserve SUCCESS AND NOTHING LESS...
Output should be
Longest word : examinations

28. (a) Consider the following tables GARMENT and FABRIC. Write SQL commands for the statements (i) to (iv).
TABLE: GARMENT
GCODE DESCRI-PTION PRICE FCODE READY-DATE
10023 PENCIL SKIRT 1150 F03 19-DEC-08
10001 FORMAL SHIRT 1250 F01 12-JAN-08
10012 INFORMAL SHIRT 1550 F02 06-JUN-08
10024 BABY TOP 750 F03 07-APR-07
10090 TULIP SKIRT 850 F02 31-MAR-07
10019 EVENING GOWN 850 F03 06-JUN-08
10009 INFORMAL PANT 1500 F02 20-OCT-08
10007 FORMAL PANT 1350 F01 09-MAR-08
10020 FROCK 850 F04 09-SEP-07
10089 SLACKS 750 F03 20-OCT-08

TABLE: FABRIC
FCODE TYPE
F04 POLYSTER
F02 COTTON
F03 SILK
F01 TERELENE
(i) To display GCODE and DESCRIPTION of each GARMENT in descending order of GCODE.
(ii) To display the details of all the GARMENTs, which have READYDATE in between 08-DEC-07 and 16-
JUN-08 (inclusive of both the dates).
(iii) To display the average PRICE of all the GARMENTs. Which are made up of FABRIC with FCODE as F03.
(iv) To display FABRIC wise highest and lowest price of GARMENTs from GARMENT table.
(Display FCODE of each GARMENT alongwith highest and lowest price.)
(b) Write a command to remove all the records of a table “Shipping”.

29. Write the definition of a function Reverse (x) in Python, to display the elements in reverse order such that each
displayed element is the twice of the original element (element *2) of the List x in the following manner:
Example :
If List x contains 7 integers is as follows:
x [0] x [1] x [2] x [3] x [4] x [5] x [6]
4 8 7 5 6 2 10
After executing the function, the array content should be displayed as follows:
20 4 12 10 14 16 8

30. Julie has created a dictionary containing names and marks as key value pairs of 6 students. Write a program, with
separate user defined functions to perform the following operations
(a) Push the keys (name of the student) of the dictionary into a stack, where the corresponding value (marks) is
greater than 75.
(b) Pop and display the content of the stack.
For example If the sample content of the dictionary is as follows
R={“OM”:76, “JAI”:45, “BOB”:89, “ALI”:65, “ANU”:90, “TOM”:82}
The output from the program should be
TOM ANU BOB OM
o
Alam has a list containing 10 integers. You need to help him create a program with separate user defined functions
to perform the given operations based on this list.
(a) Traverse the content of the list and push the even numbers into a stack.
(b) Pop and display the content of the stack.
For example, If the sample content of the list is as follows
N = [12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be:
38 22 98 56 34 12

Section - D
31. Red Pandas Infosystems has its 4 blocks of buildings. The number of computers and distances between them is
given below :

Building Number of Computers


HR 15
ADMIN 100
SYSTEM 25
PERS 30

Building Distance
HR -Admin 10 m
HR- System 50 m
HR- Pers 750 m
Admin- System 300 m
Admin- Pers 20 m
System-Pers 250 m
Answer the following questions with respect to the above :
(i) Suggest a suitable cable layout for the network.
(ii) Suggest the best place to house the server of the network.
(iii) Which topology should be used to connect computers in each building?
(iv) What kind of network will be formed here? (LAN/MAN/WAN)
(v) Write one advantage of the topology suggested by you.

32. (a) Find the output of the following Python program:


def makenew (mystr):
newstr = “”
count = 0
for i in mystr:
if count%2!=0:
newstr = newstr + str (count)
else:
if islower (i):
newstr = newstr + upper (i)
else:
newstr = newstr + i
count + = 1
newstr = newstr + mystr [:1]
print(“The new string is:”,
newstr)
makenew(“sTUdeNT”)
(b) Consider the table Student whose fields are
Scode Name Age Strcde Points Grade
101 Amit 16 1 6 NULL
102 Arjun 13 3 4 NULL
103 Zaheer 14 2 1 NULL
104 Gegen 15 5 2 NULL
105 Kumar 13 6 8 NULL
Write the Python code to update grade to ‘A’ for all these students who are getting more than 8 as points.
The table structure is as follows :
Scode : integer
Name : varchar
Age : integer
Strcde : integer
Points : integer
Grade : varchar
Note the following to establish the connection between Python and MySQL:
Host : localhost
Username : Admin
Password : Admin@123
The table exists in MySQL database as : Student
o
(a) Write a Python program to remove the characters of odd index values in a string.
(b) Consider the table MobileStock with following fields
M_Id. M_Name, M_Oty, M_Supplier
Write the Python code to fetch all records with fields M_Id, M_Name and M_Supplier from database Mobile.
Consider:
host : localhost
UserName : root
Password : system
Database : Mobile

33. What is CSV file?


Write a program using two functions :
(a) addCustomer( ): To write Customer code, Customer name and Amt in file “cust.csv”.
The details of the customers are as follows :
[‘CustCode’, ‘CustName’, ‘Amount’]
[‘001’, ‘Nihir’, ‘8000’]
[‘104’, ‘Akshay’, ‘5000’]
(b) readCustomer( ): To read the details of the customers and display them.
 o
When do we use CSV file?
Write a program using following functions :
(a) getlnventory() : Write code to accept as many inventory records and store them to the csv file Inventory.csv
storing records of inventory as per following structure
PCode Invname Price Reorder
(b) Display() : To display the detail that store in Inventory.csv

Section - E
34. Consider the table MOVIE DETAILS given below
Table : MOVIEDETAILS
MOVIEID TITLE LANGUAGE RAT-ING PLAT-FORM
M001 Minari Korean 5 Netflix
M004 MGR Magan Tamil 4 Hotstar
M010 Kaagaz Hindi 3 Zee5
M011 Harry Potter and the English 4 Prime Video
Chamber of Secrets
M015 Uri Hindi 5 Zee5
M020 Avengers: Endgame English 4 Hotstar
(i) Identify the degree and cardinality of the table.
(ii) Which field should be made the primary key? Justify your answer.
(iii) Write statements to :
(a) Delete the records whose language is “English”
(b) Add a new record : “M050”, “Palki”,“Hindi”, 5, “Amazon Prime”.
 o
(Option for part (iii) only)
Write statements to :
(a) Add a new column “DAYS” of type integer
(b) Remove the column “RATING”

35. Below is a program to delete the line having word (passed as argument). Answer the questions that follow to execute
the program successfully.
import ......
def filedel (word):
file1 = open (“Python. txt ”,
“......”)
nfile = open (“algo1.txt”, “w”)
while True:
line = file1.readline( )
if not line:
break
else :
if word in line :
......
else :
print(line)
nfile......(line)
file1.close()
nfile.close()
filedel (‘write’)
(i) Name the module that should import in Line 1.
(ii) In which mode, above program should open the file to delete the line?
(iii) Fill the blank in Line 11 and Line 14.
Page 1 NODIA Sample Paper 2 Computer Science Class 12

Sample Paper 2
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A
1. Given L= [2,3,4,5,6]. The output of print(L[–2]) is
(a) 6 (b) Error
(c) 5 (d) 3

2. The method used to get the position of file pointer is


(a) tell() (b) get()
(c) seek() (d) pos()

3. This function is used to calculate total occurrence of given elements of list.


(a) len() (b) sum()
(c) count() (d) extend()

4. You can repeat the elements of the tuple using which operator?
(a) * (b) +
(c) ** (d) %

5. The rule of referential integrity is based on...........


(a) Primary key (b) Foreign key
(c) Alternate key (d) None of these

6. Which method returns the next row from the result set as tuple?
(a) fetchone () (b) fetchmany ()
(c) fetchall () (d) rowcount

7. Which of the following command displays the attributes of a table along with their types and sizes?
(a) Alter (b) Show structure
(c) Show create table (d) View structure

8. The............command adds records to a table.


(a) ADD (b) APPEND
(c) ADDRECORD (d) INSERT
9. In a............topology, the nodes are connected by separate cables.
(a) Star (b) Bus
(c) Tree (d) Mesh

10. Given a list Lst= [45,100,20,30,50]. What will be the output of Lst[: :]?
(a) [45,100,20,30,50] (b) [ ]
(c) Error (d) [45]

11. State True or False


“Given a dictionary Studict. The statement Studict.items() displays the keys of the item only.”

12. Which module is to be imported to use the floor() function?


(a) statistics (b) matplotlib
(c) random (d) math

13. Which function is used to convert string into tuple?


(a) string() (b) tup()
(c) tuple() (d) str_tuple()

14. A file can be opened both for reading and writing using............mode.
(a) r (b) r+
(c) a (d) None of these

15. The..........clause can be used as an alternative to multiple OR.


(a) IN (b) BETWEEN
(c) NOT (d) range

16. The purpose of the primary key in a database is to


(a) unlock the database
(b) provide a map of the data
(c) uniquely identify a record
(d) establish constraints on database operations

Directions : (Q.Nos.-17 and 18) are Assertion and Reason based Questions.

17. Assertion (A) To use the randint() function , the random module needs to be included in the program.
Reason (R) Some functions are present in modules and to use them the respective module needs to be imported.
(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.

18. Assertion (A) The contents of a Binary file are not directly interpretable.
Reason (R) Modes in which binary files can be opened are suffixed with ‘b’ like : rb/wb etc.
(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.
(a) A is true but R is false.
(c) A is false but R is true.
Section - B
19. Find the error(s).
L1 = [7, 2, 3, 4] Statement 1
L2 = L1 + 2 Statement 2
L3 = L1 * 2 Statement 3
L = L1.pop(7) Statement 4
20. Name two switching techniques used to transfer data between two terminals (computers).
 o
Arrange the following network in ascending order of their area:
LAN, PAN, WAN, MAN

21. (a) Observe the code and write the output:


t = ‘HELLO’
t1 = tuple(t)
print(t1)
(b) Predict the output of the following code
x = (1, 2, 3)
y = (3, 4)
t = x + y
print(t)

22. Differentiate between an attribute and a tuple with an example.

23. (a) Write the hill forms of


(i) WVVW
(ii) TCP/IP
(b) List down the types of computer networks.

24. Identify the output of the following Python code.


D = {1: “One”, 2: “Two”, 3: “Three”}
L = [ ]
for K, V in D.items():
if V[0] = = “T”:
L.append (K)
print(L)
 o
Identify the output of the following Python statement.
lst1 = [10, 15, 20, 25, 30]
lst1.insert(3, 4)
lst1.insert(2, 3)
print (lst1[– 5])

25. Describe the following terms


(i) Domain
(ii) DB2
 o
Identify commands/functions for the following actions :
(i) To add a new column to a table.
(ii) To get the sum of all values in a column of a table.

Section - C

26. (a) Consider the tables CARS and SUPPLIER given below. What will be the output of the statement given?
TABLE: CARS
Ccode Car-Name Make Color Capa-city Cha-rges Scode
501 A-star Suzuki RED 3 14 1
503 Indigo Tata SILVER 3 12 2
502 Innova Toyota WHITE 7 15 2
509 SX4 Suzuki SILVER 4 14 2
510 C-Class Merc-edes RED 4 35 4

Table : SUPPLIER
Scode Sname
1 Great Suppliers
2 Himalayan Vehicles
3 Road Motors
4 Speed
SELECT CarName, Sname, Charges FROM CARS C, SUPPLIER S WHERE C.Scode= S. Scode
AND Charges > 15;
(b) Write the output for SQL queries (i) to (iv), which are based on the table CARDEN.
TABLE: CARDEN
Ccode CarName Make Color Capa-city Charges
501 A-star Suzuki RED 3 14
503 Indigo Tata SILVER 3 12
502 Innova Toyota WHITE 7 15
509 SX4 Suzuki SILVER 4 14
510 C-Class Mercedes RED 4 35
(i) SELECT COUNT(DISTINCT Make) FROM CARDEN;
(ii) SELECT COUNT(*) Make FROM CARDEN;
(iii) SELECT CarName FROM CARDEN WHERE Capacity = 4;
(iv) SELECT SUM (Charges) FROM CARDEN WHERE Color = “SILVER”;

27. Write a function Del() to delete the 4th word from a text file school.txt.
 o
Write a function countmy( ) in Python to read the text file “Data.txt” and count the number of times “my” occurs
in the file.
For example If the file contents are:
My first book was. Me and My Family.
It gave me chance to be known to the world.
The output of the function should be
No. of times “my” occur : 2

28. (a) Write the output of the queries (i) to (iv) based on the table FURNITURE given below.
Table : FURNITURE
FID NAME DATE OF PURCHASE COST DISCOUNT
B001 Double Bed 03-JAN-2018 45000 10
T010 Dinning Table 10-MAR-2020 51000 5
B004 Single Bed 19-JUL-2021 22000 0
C003 Long back Chair 30-DEC-2016 12000 3
T006 Console Table 17-NOV-2019 15000 12
B006 Bunk bed 01-JAN-2021 28000 14
(i) SELECT SUM(DISCOUNT) FROM FURNITURE WHERE COST>15000;
(ii) SELECTMAX(DATEOFPURCHASE) FROM FURNITURE;
(iii) SELECT
* FROM FURNITURE WHERE DISCOUNT>5 AND FID LIKE “T%”;
(iv) SELECTDATEOFPURCHASE FROM FURNITURE WHERE NAME IN (“Dinning Table”, “Console
Table”);
(b) Write a command to remove all the records of the table “Garments” whose Readydate is after “20-Oct-2008”.

29. Write a user-defined function find-name (name), where name is an argument in Python to delete phone number from
a dictionary phone-book on the basis of the name, where name is the key.

30. Write Push (contents) and Pop (contents) methods in Python to add numbers and remove numbers considering them
to act as Push and Pop operations of stack.
 o
Write the Push operation of stack containing person names. Notice that the name should only accept characters,
spaces and period (.) except digits. Assume that Pname is a class instance attribute.

Section - D

31. Sony corporation has set up its 4 offices in the city of Srinagar, with its offices X, Z, Y, U:

Branch to Branch distance is given below:


X to Z 40 m
Z to Y 60 m
Y to X 135 m
X to U 70 m
Z to U 165 m
Z to U 80 m
Number of computers in each of the offices is as follows:
X 50
Z 130
Y 40
U 15
(i) Suggest a suitable cable layout of connectivity of the offices.
(ii) Suggest placement of server in the network with suitable reason.
(iii) Suggest placement of following devices in the network:
(a) Switch/Hub
(b) Repeater
(iv) Suggest a suitable topology for connecting the computers in each building.
(v) Write any one advantage of the topology suggested.

32. (a) Carefully observe the following Python code and answer the question that follow:
x = 5
def func2():
x = 3
global x
x = x + 1
print(x)
print(x)
On execution the above code, produces the following output:
6
3
Explain the output with respect to the scope of the variables.
(b) Write the code to create a table Product in database Inventory with following fields
Fields Datatype
PID varchar(5)
PName char(30)
Price float
Rank varchar(2)
Note the following to establish the connection between Python and MySQL:
Host : localhost
Username : system
Password : hello
Database : Inventory
 o
(a) Find the output of the following program:
def calcresult ():
i=9
while i>1 :
if(i%2 = = 0):
x = i%2
i = i – 1
else:
i = i – 2
x = i
print(x**2)
(b) Which data will get added in table Company by following code?
import mysql.connector
con = mysql.connector.connect (
host = “localhost”,
user = “system”,
passwd = “hello”,
database = “connect”).
cur = con.cursor ( )
sql = “insert into Company (Name,
Dept, Salary) values (%s,
%s, %s)”
val = (“ABC”, “DBA”, 35000)
cur.execute (sql.val)
con.commit ( )
Consider :
host : localhost
UserName : system
Password : hello
Database ; connect

33. Does python create a file itself if the file doesn’t exist in the memory? Illustrate your answer with an example:
Write a program using following functions :
(a) inputStud() :To input details of as many students and add them to a csv file “college.csv” without removing the
previous records.
SrNo Studname City Percentage
(b) readCollege() : To open the file “college.csv” and display records whose city is “Kolkata”
 o
Write a statement to create a data.txt file with the following text.
Python file handling is very interesting and useful.
Write a python code using two functions as follows
(a) removerow( ) : To remove a record from the college file “College.csv” having following structure.
SrNo Studname City Percentage
(b) getCollege( ) : To read the records of the college file “College.csv” and display names of students whose names
start with a lowercase vowel.
Section - E

34. Consider the table APPLICANTS


TABLE: APPLICANTS
No NAME FEE GEN-DER C_ID JOINYEAR
1012 Amandeep 30000 M A01 2012
1102 Avisha 25000 F A02 2009
1103 Ekant 30000 M A02 2011
1049 Arun 30000 M A03 2009
1025 Amber 40000 M A02 2011
1106 Ela 40000 F A05 2010
1017 Nikita 35000 F A03 2012
1108 Arluna 30000 F A03 2012
2109 Shakti 35000 M A04 2011
1101 Kirat 25000 M A01 2012
(i) Which field qualifies to be the Primary key.
(ii) If all the records of Male applicants are deleted, what will be the cardinality of the table.
(iii) Write statements to
(a) Increase FEE of “M” (Male) applicatnts by 2000.
(b) Display details of “F” (Female) applicants in descending order of FEE.
 o
(Option for part (iii) only)
Write statements to
(a) Change width of column FEE to 20.
(b) Remove the column C_ID.

35. Given below is a code to open a text file and perform some operations on it. Answer questions with respect to the
code given
myfile=open(“detail.txt”, “r”)
s =.......... Line 2
print(s)
myfile.close( )
(i) In which mode is the file opend?
(ii) If the entire file is to be read, write a statement in place of Line 2.
(iii) What is the original code performing?
Page 1 NODIA Sample Paper 3 Computer Science Class 12

Sample Paper 3
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A

1. What is default value of host?


(a) host (b) localhost
(c) globalhost (d) None of these

2. Which of the following SQL commands displays the structure of a table?


(a) ALTER (b) STRUCTURE
(c) DESCRIBE (d) SHOW DATA

3. State True or False


“Lists and dictionaries are mutable.”

4. Which of the following is the correct output for the execution of the following Python statement?
print(5+3**2/2)
(a) 32 (b) 8.0
(c) 9.5 (d) 32.0

5. Which path does not start with a leading forward slash ?


(a) Relative (b) Absolute
(c) Both (a) and (b) (d) None of these

6. _____command adds a primary key to a table after it has been already created.
(a) MODIFY (b) ADD PRIMARY
(c) ALTER (d) ADD KEY

7. The clause to get the unique values from a field of a table is


(a) MAX (b) UNIQUE
(c) DISTINCT (d) None of these
8. Observe the following tuples and choose the correct option
t1=(4, 7, 8, 9)
t2=(0, 4, 3)
>>>t=t1+t2
>>>print(t)
(a) (4, 7, 8, 9, 0, 4, 3) (b) (4, 7, 8, 9, 4, 7, 8, 9)
(b) (4, 7, 8, 9) (d) None of these

9. ______is an attribute that makes a link between two tables to fetch corresponding data.
(a) Primary key (b) Secondary key
(c) Foreign key (d) Composite key

10. Assume that the position of the file pointer is at the beginning of 3rd line in a text file. Which of the following option
can be used to read all the remaining lines?
(a) myfile.read(n-3) (b) myfile.read(n)
(c) myfile.readline( ) (d) myfile.readlines( )

11. ______is a protocol used for uploading and downloading of files in a network.
(a) SMTP (b) FTP
(c) PPP (d) VoIP

12. sub = “PYTHON”


for i in sub:
print (i, ‘ ’, end = “ ”)
P
Y
T
(a) PYTHON (b) H
O
N

(c) None (d) P, Y, T, H, O, N

13. In complex number a + ib, b represents as


(a) real part (b) imaginary part
(c) special part (d) None of these

14. Given an object obj1= (10, 20, 30, 40, 50, 60, 70, 80, 90). What will be the output of print(obj1[3:7:2])?
(a) (40,50,60,70,80) (b) (40,50,60,70)
(c) (40,50,60) (d) (40,60)

15. Which of the following function returns the total number of values?
(a) MAX (b) MIN
(c) COUNT (d) SUM
16. Which of the following is the correct output for the following execution ?
print(print(“Biscope”))
(a) Biscope (b) None
(c) Biscope (d) Error
None

Directions : (Q. Nos. 17 and 18) are Assertion and Reason based questions.

17. Assertion (A) A Python function that accepts parameters can be called without any parameters. Reason (R) Functions
can carry default values that are used, whenever values are not received from calling function.
(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.

18. Assertion (A) A CSV file is by default delimited by comma(,), but the delimiter character can be changed.
Reason (R) The writerow() function for CSV files has a “delimiter” parameter that can be used to specify the
delimiter to be used for a CSV file.
(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

19. What will be the output for the following Python statement?
L = [10, 20, 30, 40, 50]
L = L + 5
print(L)

20. Write any two disadvantages of star topology.


 o
Why is a switch called an intelligent hub?

21. (a) What will be the output of the following Python code?
L =[10, 20]
L1=[30, 40]
L2=[50, 60]
L. append (L1)
L.extend(L2)
print(L)
(b) Find the output
>>> l1 = [1,2,3,4]
>>> l2 = [1,2,3,4]
>>> l1 > l2
22. Mention the various advantages of using a DBMS.

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


(i) WAN (ii) GSM
(b) Write down the expansion of Modem. Also, write its role in a network.

24. Write the output of given code :


x = (1, 2, 3)
y = (3, 4)
t = x + y
print(t)
 o
Observe the following tuple and answer the questions that follow:
t1 = (70, 56, ‘Hello’, 22, 2, ‘Hi’, ‘The’, ‘World’, 3)
(i) t1[2 : 4] (ii) t1[– 6]

25. If R1 is a relation with 8 rows and 5 columns, then what will be the cardinality of R1?
If 5 rows are added more, what will be the Degree of the table now ?
 o
Identify commands/functions for the following actions
(i) To display only records of Trains from the Train table whose starting station is “NDLS”. (Column for starting
station is “Start”, table name is “Train”)
(ii) To get the average of percentage of students (Table name : “Student” , Percentage column : “Perc”).

Section - C
26. (a) Consider the tables CITY and LOCATION given below.
Table : CITY
Field Name Data Type Remarks

CITYCODE CHAR(5) Primary Key

CITYNAME CHAR(30)

SIZE INTEGER

AVGTEMP INTEGER

POPULATIONRATE INTEGER

POPULATION INTEGER
Table: Location
Citycode Lname
C1 East
C2 West
C3 South
C4 North
Write a command to display the Cityname and corresponding Location name (Lname), where the average temperature
is greater than 35 from the tables.
(b) Write outputs for the SQL commands (i) to (iv) based on the table CUSTOMER given below:
TABLE: CUSTOMER
CID CNAME GENDER SID AREA

1001 R SHARMA FEMALE 101 NORTH

1002 M R TIWARY MALE 102 SOUTH


1003 M K KHAN MALE 103 EAST

1004 A K SINGH MALE 102 EAST

1005 S SEN FEMALE 101 WEST

1006 R DUBEY MALE 104 NORTH

1007 M AGARWAL FEMALE 104 NORTH

1008 S DAS FEMALE 103 SOUTH

1009 R K PATIL MALE 102 NORTH

1010 N KRISHNA MURTY MALE 102 SOUTH


(i) SELECT COUNT(*), GENDER FROM CUSTOMER GROUP BY GENDER;
(ii) SELECT CNAME FROM CUSTOMER WHERE CNAME LIKE ‘L%’;
(iii) SELECT DISTINCT AREA FROM CUSTOMER;
(iv) SE.LECT’COUNT(*) FROM CUSTOMER WHERE GENDER=“MALE”;

27. Write a Python program that read the data from file ‘original.dat’ and delete the line(s) having word (passed as an
argument). Then write these data after removing lines into file ‘duplicate.dat’.
 o
Write a program in Python to open a text file “lines.txt” and display all those words whose length is greater than 5.

28. (a) Answer the questions (i) to (iv) on the basis of the following tables SHOPPE and ACCESSORIES.
TABLE: SHOPPE
Id SName Area
S001 ABC Computeronics CP
S002 All Infotech Media GK II
S003 Tech Shoppe CP
S004 Geeks Tecno Soft Nehru Place
S005 Hitech Tech Store Nehru Place

TABLE: ACCESSORIES
No Name Price Id

A01 Mother Board 12000 S01


A02 Hard Disk 5000 S01

A03 Keyboard 500 S02

A04 Mouse 300 S01


A05 Mother Board 13000 S02

A06 Keyboard 400 S03

A07 LCD 6000 S04

T08 LCD 5500 S05

T09 Mouse 350 S05


T10 Hard Disk 4500 S03

(i) To display Name and Price of all the ACCESSORIES in ascending 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.
(b) Write a command to add a new column Remarks varchar(30) to the ACCESSORIES table storing remarks about
the product.

29. Write a userdefined function parser(L) that accepts a list as parameter and creates another two lists storing the
numbers from the original list , that are even and numbers that are odd.

30. Consider the following stack of characters, where STACK is allocated N = 8 memory cells.
STACK : A, C, D, F, K,...,...,...
Describe the STACK at the end of the following operations. Here, Pop and Push are algorithms for deleting and
adding an element to the stack.
(i) Pop (STACK, ITEM)
(ii) Pop (STACK, ITEM)
(iii) Push (STACK, L)
(iv) Push (STACK, P)
(v) Pop (STACK, ITEM)
(vi) Push (STACK, R)
(vii) Push (STACK, S)
(viii) Pop (STACK, ITEM)
 o
Consider the following sequence of numbers:
1, 2, 3, 4
These are supposed to be operated through a stack to produce the following sequence of numbers:
2, 1, 4, 3
List the Push and Pop operations to get the required output.

Section D

31. Trine Tech Corporation (TTC) is a professional consultancy company. The company is planning to set up their
new offices in India with its hub at Hyderabad. As a network adviser, you have to understand their requirement and
suggest them the best available solutions. Their queries are mentioned as (i) to (v) below.

Block (From) Block (To) Distance


Human Resource Conference 110
Human Resource Finance 40
Conference Finance 80
Expected number of computers to be in each block
Block Computers
Human Resource 25
Finance 120
Conference 90
(i) Which will be the most appropriate block, where TTC should plan to install their server?
(ii) Draw a block to block cable layout to connect all the buildings in the most appropriate manner for efficient
communication.
(iii) Suggest a suitable topology to connect the computers in each building.
(iv) Which of the following device will be suggested by you to connect each computer in each of the buildings?
(a) Switch/Hub (b) Modem (c) Gateway
(v) Company is planning to connect its offices in Hyderabad which is less than 1 km. Which type of network will
be formed?

32. (a) What will be the output of the following code?


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)
(b) Given below is a table Item in database Inventory.
ItemID ItemName Quantity UnitPrice
101 ABC 5 120
102 XYZ 7 70
103 PQR 8 65
104 XYZ 12 55
Riya created this table but forget to add column ManufacturingDate. Can she add this column after creation of table?
If yes, write the code where user’s name and password are system and test respectively.
Note the following to establish the connection between Python and MySQL:
Host : localhost
Username : system
Password : test
Database : Inventory
 o
(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) Consider the following table structure
Table: Faculty
F_ID(P)
Fname
Lname
Hire_date
Salary
Write the Python code to create the above table.
Consider :
host : localhost
UserName : root
Password : system
Database :School

33. What do you mean by file? What do you mean by file handling?
Write a program code in python to perform the following using two functions as follows :
(a) addBook( ) : to write to a csv file “book.csv” file book no, book name and no of pages with separator as tab.
(b) countRecords( ) : To count and display the total number of records in the “book.csv” file
 o
Explain open( ) function with its syntax.
Write python code to perform the following using two user defined functions.
(a) showData() : To display only roll no and student name of the file “student.csv”

RollNo, Name, Marks


1, Nilesh, 65
2, Akshay, 75
(b) showSelect( ) : To display only roll number and marks of the students from the csv file “student.csv”

Section-E

34. Consider the following table STORE and answer the questions:
TABLE: STORE
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpener Classic 23 60 8 31-JUN-09
2003 Balls 22 50 25 01-FEB-10
2002 Gel Pen Premium 21 150 12 24-FEB-10
2006 Gel Pen Classic 21 250 20 11-MAR-09
2001 Eraser Small 22 220 6 19-JAN-09
2004 Eraser Big 22 110 8 02-DEC-09
2009 Ball Pen 0.5 21 180 18 03-NOV-09
(i) What is the degree of the table?
(ii) Write the syntax of the SQL command to change data of the table.
(iii) Write statements to :
(a) Display the number of distinct Scodes.
(b) Display the maximum and minimum quantities.
(Option for part (iii) only)
Write statements to :
(a) Display the structure of the STORE table.
(b) Add a new column Location varchar(50) in the table to store the location details of the items.

35. Given below is a code to open a text file “para.txt” and display the lines that begin with “A”.Some of the codes are
missing . Write codes to fill up the blanks :
myf=open(... ,...) Blank 1 , Blank 2
lines=myf....... . Blank 3
for ln in .... . . : Blank 4
if ln[0]= = “A”:
print(ln)
(i) Write the missing code for Blank 1.
(ii) Write the missing code for Blank 2.
(iii) Write the missing code for Blank 3 and Blank 4.
Page 1 NODIA Sample Paper 4 Computer Science Class 12

Sample Paper 4
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A
1. Given L= [2,3,4,5,6]. The output of print(L[–1:–5]) is
(a) [6,5,4] (b) Error
(c) [ ] (d) [6,5]

2. Rows of a relation are called


(a) relation (b) tuples
(c) data structure (d) an entity

3. If a table carries 10 columns and 15 rows, what is its degree?


(a) 10 (b) 150
(c) 15 (d) 25

4. The...........function returns True if all the characters in a string are digits.


(a) isalnum() (b) isdigit()
(c) isnumber() (d) isalpha()

5. The seek(n) places the file pointer at position n with reference to


(a) Beginning (b) End
(c) Current position (d) Position 10

6. Given a tuple t= (2,5,1,6,3). The statement t.sort() returns


(a) (1,2,3,5,6) (b) (6,5,3,2,1)
(c) Error (d) None of these

7. t1=(9,6,7,6)
t2=(2.8,12,20)
The output of the statement below is
print( min(t1) + max(t2))
(a) 26 (b) 25
(c) Error (d) None of these
8. State True or False
“The method that can be used to delete a range of values from a list is del”.

9. In which module, ceil() function resides ?


(a) pandas (b) pyplot
(c) random (d) math

10. To see a list of all the databases in the system , the..............command may be used.
(a) Show (b) Show databases
(c) Display databases (d) View databases

11. Which among the following are constraints ?


(a) Primary key (b) Unique
(c) NOT NULL (d) All of these

12. in and not in are........Operators.


(a) Arithmetic (b) Membership
(c) Logical (d) Identity

13. Modulation and demodulation is performed by


(a) microwave (b) satellite
(c) modem (d) gateway

14. A set of possible data values is called


(a) attribute (b) degree
(c) tuple (d) domain

15. The..........attribute of the connection string specifies the password to connect to the database.
(a) code (b) password
(c) passwd (d) All of these

16. While opening a binary file the.........character has to be added to the mode of opening.
(a) b (b) x
(c) u (d) b*

Directions (Q.Nos. 17-18) are Assertion and Reason based questions.

17. Assertion (A) A function with 3 formal parameters must be called with 3 actual parameters.
Reason (R) Since, all the formal parameters are used to produce the output from the function , the function expects
the same number of parameters from the function call.
(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.

18. Assertion (A) A binary file uses the dump() function to write data into it.
Reason (R) The load() function reads data from a binary file.
(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
19. What will be the output of following code ?
L=[10,30,50,60]
L.append(70)
L.insert(2,80)
L.sort()
print(L)

20. Write 2 advantage and 2 disadvantage of bus topology.


 o
Which part of TCP/IP is responsible for dividing a file or message into very small parts, at the source computer?
Also, define, TCP/IP.

21. Find outputs of following code.


(a) L=[118,16,[20,30,50],120]
L1=[12,16,17]
L.extend(L1)
print(L[2][2])
print(L)
(b) t1=(9,6,1,12)
t2=(10,11,12)
print(t1+t2)
print(t1*2)
print(t2–t1)

22. What do you understand by primary key? Give a suitable example of primary key from a table containing some
meaningful data.

23. (a) Write the full forms of


(i) LAN (ii) XML
(b) What was the role of ARPANET in the computer network?

24. What will be the output of the following code, when executed?
d={‘Name’: ‘Ram’,‘Subjects’:[‘Eng’, ‘Physics’, ‘CS’], ‘Marks’:[67,78,90]}
print(d[‘Subjects’])
print(d[‘Subjects’][2])
 o
What will be the output of the following code, when executed?
tupnames=(“India”, “Australia”,
(“UK”, “Nepal”), “Bangladesh”)
print(tupnames[5 : ])
print(tupnames[2][1])

25. List the major components of a database system.


 o
What is join? What are the different kinds of joins?
Section C

26. (a) Consider the tables Student and House given below. What will be the output of the statement given?
Table: Student
Rno Sname Class Hcode
1 Raj 12ScA C1
2 Shekhar 11ComC C2
3 Ravi 12HumB C2
4 Jaisnav 12ScB C3

Table: House
Hcode Lname
C1 East
C2 West
C3 South
C4 North
SELECT S.Sname , H.Lname FROM Student S, House H WHERE S.Hcode = H.Hcode AND
SName LIKE “R%”;
(b) Consider the following table STORE and answer the questions
TABLE: STORE
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpener Classic 23 60 8 31-JUN-09
2003 Balls 22 50 25 01-FEB-10
2002 Gel Pen Premium 21 150 12 24-FEB-10
2006 Gel Pen Classic 21 250 20 11-MAR-09
2001 Eraser Small 22 220 6 19-JAN-09
2004 Eraser Big 22 110 8 02-DEC-09
2009 Ball Pen 0.5 21 180 18 03-NOV-09
Write SQL commands for the following statements:
(i) To display details of all the items in the STORE table in ascending order of LastBuy.
(ii) To display ItemNo and Item name of those items from STORE table, whose Rate is more than `15.
(iii) To display the details of those items whose Supplier code (Scode) is 22 or Quantity in Store (Qty) is more than
110 from the table STORE.
(iv) To display minimum rate of items for each Supplier individually as per Scode from the table STORE.

27. Write a program to accept a filename and a position. Using the inputs, call a function SearchFile(Fname, pos) to
read the contents of the file from the position to the end. Now, display all those words that start with “U” or “u”.
 o
Write a program to search a Employee record according to Id from the “emp.txt” file. The “emp.txt” file contains
Id, Name and Salary fields. Assume that first field of the employee records (between Id and Name) is separated with
a comma(,).
28. (a) Consider the following tables GARMENT and FABRIC. Write SQL commands for the statements (i) to (iv).
TABLE: GARMENT
GCODE DESCRIPTION PRICE FCODE READY-DATE
10023 PENCIL SKIRT 1150 F03 19-DEC-08
10001 FORMAL SHIRT 1250 F01 12-JAN-08
10012 INFORMAL SHIRT 1550 F02 06-JUN-08
10024 BABY TOP 750 F03 07-APR-07
10090 TULIP SKIRT 850 F02 31-MAR-07
10019 EVENING GOWN 850 F03 06-JUN-08
10009 INFORMAL PANT 1500 F02 20-OCT-08
10007 FORMAL PANT 1350 F01 09-MAR-08
10020 FROCK 850 F04 09-SEP-07
10089 SLACKS 750 F03 20-OCT-08

TABLE: FABRIC
FCODE TYPE
F04 POLYSTER
F02 COTTON
F03 SILK
F01 TERELENE
(i) To display GCODE and DESCRIPTION of each GARMENT in descending order of GCODE.
(ii) To display the details of all the GARMENTs, which have READYDATE in between 08-DEC-07 and 16-
JUN-08 (inclusive of both the dates).
(iii) To display the average PRICE of all the GARMENTs. Which are made up of FABRIC with FCODE as F03.
(iv) To display FABRIC wise highest and lowest price of GARMENTs from GARMENT table. (Display
FCODE of each GARMENT along with highest and lowest price.)
(b) Write a command to remove the records of the garments whose READYDATE is after DEC-2008.

29. Write a user defined function change(L) to accept a list of numbers and replace the number in the list with its
factorial.
Example :
Input : [3,4,5,6,7]
Output: [6, 24, 120, 720, 5040]

30. Suppose STACK is allocated 6 memory locations and initially STACK is empty (Top = 0). Given the output of the
program segment:
AAA = 4
BBB = 6
Push (STACK, AAA)
Push (STACK, 4)
Push (STACK, BBB +2)
Push (STACK, AAA + BBB)
Push (STACK, 10)
while (Top>0):
Element = STACK.Pop( )
print(Element)
o
Consider the following operations are done on a stack. What will be the final status of the stack after all the
operations are performed.
(a) Push(True) (b) Push(False) (c) Push(10)
(d) Pop() (e) Push(50) (f) Push(70)
(g) Pop() (h) Pop()

Section D
31. Granuda consultants are setting up a secured network for their office campus at Faridabad for their day-to-day office
and web based activities. They are planning to have connectivity between 3 buildings and the head office situated
in Kolkata.
Answer the questions (i) to (v) after going through the building positions in the campus and other details, which are
given below:
Distance between various buildings
Building RAVI to Building JAMUNA 120 m
Building RAVI to Building GANGA 50 m
Building GANGA to Building JAMUNA 65 m
Faridabad Campus to Head Office 1460 km

Number of computers
Building RAVI 25
Building JAMUNA 150
Building GANGA 51
Head Office 10
(i) Suggest the most suitable place (i.e. block) to house the server of this organisation. Also, give a reason to justify
your suggested location.
(ii) Suggest a cable layout of connections between the building inside the campus.
(iii) Suggest the placement of the following devices with justification:
(a) Switch (b) Repeater
(iv) The organisation is planning to provide a high speed link with its head office situated in the Kolkata using a
wired connection. Which of the following cable will be most suitable for this job?
(a) Optical fibre (b) Co-axial cable
(c) Ethernet cable
(v) Consultancy is planning to connect its office in Faridabad which is more than 10 km from Head office. Which
type of network will be formed?

32. (a) The code given below will give an error on execution. Identify the type of the error and modify the code to
handle such type of an error.
x = int(input(“Enter the value of
x : ”))
y = int(input(“Enter the value of
y : ”))
z = x/y
print (“The value of z : ”, z)
(b) Note the following to establish the connection between Python and MySQL:
A resultset is extracted from the database using the cursor object (that has been already created) by giving the
following statement.
Mydata=cursor.fetchone( )
(i) How many records will be returned by fetchone() method?
(ii) What will be the datatype of Mydata object after the given command is executed?
 o
(a) Predict the output :
str = “Python Program”
def sTringoutput(str):
print(str[3:5])
print(str[–10])
print(str[5:])
print(str[–28])
(b) Define fetchmany([size]). How does fetchone() method differ from fetchall() method?

33. What are the advantages of CSV files?


Write a python program using following functions to :
A file “teacher.csv” contains a city, teacher name and Salamount.
(a) Search() : Search and print all rows where city is “delhi”.
Sample “teacher.csv” :
City Teacher Name Salamount
Delhi, Anil Sharma, 10000
Pune, Mr Dua, 20000
Delhi, Mr Das, 25000
(b) Searchfromfile() : From the file “teacher.csv” print all rows where teacher name is “Anil”.
 o
What are the Disadvantages of CSV files?
Write a program using functions :
(a) addTransaction() : To append bank transactions of following structure to “bank.csv”
TranlD TranDate Amount Type
(b) getTran() : To display those transactions whose type is “Deposit”.

Section E
34. Consider the following table Student:
Table : Student
AdmNo RollNo Name Class Marks
2715 1 Ram 12 90
2816 2 Shyam 11 95
2404 3 Ajay 10 92
2917 4 Tarun 12 94
(i) Can we make Class as the Primary key of the table?
(ii) What is the cardinality of the table?
(iii) Write statements to :
(a) Display the average Marks .
(b) Display the different Classes .
or (Option for part (iii) only)
Write statements to :
(a) Change the data type of Marks column so that it can take fractional values upto 2 decimals .
(b) Increase width of Name column to varchar(50).

35. The code given below opens a binary file and writes records of customer’s roomid, Name and days of stay . Some
of the codes are missing .Write codes to fill up the blanks :
import....... # Blank1
hotellst=[]
cname=“ ”
days=0.0
roomid=0
ans=‘y’
f=open(“hotel.dat”, “wb”)
print(“Welcome to my Hotel ”)
while ans== ‘y’:
roomid=input(“Enter Roomld :”)
cname=input(“Enter Customer name
:”)
days=float(input(“Enter days of
stay :”))
hotellst=[...., ....., .....]
# Blank2 To create the record to
be written .........# Blank3 To
write the data to the binary file.
ans=input(“Continue(y/n)”)
f.close()
(i) Write the missing code for Blank1.
(ii) Write the missing code for Blank2.
(iii) Write the missing code for Blank3.

 EN
Page 1 NODIA Sample Paper 5 Computer Science Class 12

Sample Paper 5
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A
1. _____command modifies or change the existing records in a table.
(a) UPDATE (b) CHANGE
(c) ALTER (d) MODIFY

2. Which of the following operator cannot be used with string data type?
(a) + (b) in
(c) * (d) /

3. Which of the following is a category of SQL commands?


(a) DDL (b) TCL
(c) DML (d) All of these

4. What is the output of the following code?


num = 4 + float (7)/int (2.0)
print (“num =”, num)
(a) num = 7.5 (b) 7.5
(c) num : 7.5 (d) Error

5. Given : s= “ComputerExam”. What will be the output of


print(s[2]+s[8]+s[1:51)?
(a) mEOMUU (b) mEompu
(c) mEomPU (d) MEompu

6. State True or False


Digits are one of the parts of the Python character set

7. The clause to arrange the data of a column in descending order is


(a) DESC (b) GROUP BY
(c) LIKE (d) ASC
8. Which of the following are the most obvious kind of constants?
(a) Keywords (b) Literals
(c) Variables (d) Identifiers

9. Which of the following types of files will need the pickle module for working on it ?
(a) Binary files (b) Text files
(c) CSV files (d) All of these

10. In the following code, which lines will give error? (Assume the lines are numbered starting from 1.)
mul=3
value=10
for i in range (1, 6, 1):
if (value % mul = 0):
print (value * multiply)
else
print (value + multiply)
(a) 4,5
(b) 4,5,6
(c) 4,5,6,7
(d) No errors

11. There can be____foreign keys in a relation.


(a) 2 (b) 3
(c) 1 (d) Multiple

12. The_____clause with the COUNT() function counts only the unique values in an attribute.
(a) UNIQUE (b) HAVING
(c) DISTINCT (d) LIKE

13. User can write Python script using


(a) MySQL.connector library (b) SQL.connect library
(c) MySQL.connect library (d) None of these

14. _____is a protocol used for remote login.


(a) HTIT (b) PPP
(c) IRCP (d) Telnet

15. Which of the following functions will read lines of a text file as list elements.
(a) read( ) (b) get()
(c) readline( ) (d) readlines( )

16. Which of the following will be the output of the statement given below?
print([12,34,56,78,90].pop())
(a) 78 (b) 90
(c) 12 (d) 12,34,56,78,90

Direction (Q.Nos. 17-18) are Assertion and Reason based questions.


17. Assertion (A) In a cross join the number of records in the output will be the maximum.
Reason (R) A cross join is also called a Cartesian product.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.

18. Assertion (A) A file that is opened using the open() function may not specify the mode of opening it.
Reason (R) If the mode is not specified , the read mode is used by default..
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.

Section B
19. Observe the given list and find the answer of questions that follows.
list1 = [23, 45, 63, ‘Hello’, 20
‘World’, 15, 18]
(i) list1[–3] (ii) list1[3]

20. What is the advantage of using switch over hub?


 o
Write some benefits of networking.

21. (a) Find the output


L = [10, 19, 45, 77, 10, 22, 2]
(i) L [3 : 5] (ii) L [: : –2]
(b) Find the error(s).
L1 = [7, 2, 3, 4]
L2 = L1 + 2
L3 = L1 * 2
L = L1.pop(7)

22. What do you understand by RDMS?

23. (a) Write the full forms of :


(i) POP (ii) HTTP
(b) Differentiate between the terms Internet and Intranet.

24. Predict the output


dic = {‘a’:1, ‘b’:2, ‘c’:3, ‘d’:4}
print(dic)
if ‘a’ in dic :
del dic[‘a’]
print(dic)
 o
Distinguish between tuple and list.

25. Explain the concept of candidate keys with the help of an appropriate example.
 o
Observe the following table carefully and write the names of the most appropriate columns, which can be considered
as (i) candidate keys and (ii) primary key.
Table: Product
CID CNAME AMOUNT COUNTRY ITEM
101 ALLE 100000 JMEKA SHOES
111 BEN 20000 FRANCE HELMET
110 RIKI 25000 AMERICA BAG
011 BRETT LEE 105000 AUSTRALIA BAT

Section C
26. (a) Consider the tables Travel and Train given below.
Table : Travel
Tcno Pname Class TId Amt
1 Rahul AC T1 2500
2 Sujit SL T2 4500
3 Ravi AC T1 6000
4 Ankita AC T3 1800

Table : Train
TId Tname
T1 Rajdhani
T2 Himgiri Exp
T3 Darjeeling Mail
Write the command to display the passenger names and the train names by which they are travelling for all passengers
travelling by “Mail” trains.
(b) Considering the tables Train and Travel given above write commands for the following :
(i) Display passenger names , corresponding train names and amounts for records where amount >5000.
(ii) Increase amount of passengers by 20% who are travelling by ‘AC”
(iii) Display a cross join of the two tables.
(iv) Remove records of passengers who are travelling by “Rajdhani”.

27. A binary file “emp.dat” contains records of employees as per following structure:
Eno Ename Salary
1 Mr. Raj 85000
h
Write a program in Python to open the Binary file “emp.dat” and display only those records where the employee
salary is greater than 75000.
 o
Write a program to read the content from a text file “status.txt”, count and display the total number of lines and blank
spaces present in it. e.g. if the “status.txt” file contains the following lines:
Welcome to your one-step solutions for all your study, practice and assessment needs for various competitive &
recruitment examinations and school segment. We have been working tirelessly for over a decade to make sure that
you have best in class study resources because you deserve SUCCESS AND NOTHING LESS...
The output will be:
The status file contents are
Total lines in file are: 4
Total spaces in file are: 43

28. (a) Consider the following tables SENDER and RECIPINT. Write SQL commands for the statements (i) to (iv).
TABLE: SENDER
SenderlD 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 Prasad 122-K, SDA New Delhi

TABLE: RECIPIENT
RecID SenderlD 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 East Mumbai
MU32 MU15 P K Swamy B5, C S Terminus Mumbai
ND48 ND50 S Tripathi 13, B1 D, Mayur New Delhi
Vihar
(i) To display the names of all Senders from Mumbai.
(ii) To display the RecID, SenderName, SenderAddress, RecName, RecAddress for every Recipient.
(iii) To display Recipient details in ascending order of RecName.
(iv) To display number of Recipients from each City.
(b) Display the Sender name and corresponding Recipient name from the tables where sender is from “NEW
DELHI” and recipient is from “KOLKATA”.

29. Write a user defined function change(L) to accept a list of numbers and replace the numbers in the list with their
sum of digits.
Example
Input : [32,142,215,26,7]
Output : [5, 7 , 8 , 8, 8,7]

30. Write Push (contents) and Pop() methods in Python to add numbers and remove numbers considering them to act as
Push and Pop operations of stack.
 o
Find the final contents of a stack on which the following operations are done.
1. Push(100) 2. Push(200)
3. Push(50) 4. Push(50)
5. Pop() 6. Push()
7. Pop(2) 8. Pop()

Section D
31. Freshminds University of India is starting its first campus in Ana Nagar of South India with its centre admission
office in Kolkata. The university has three major blocks comprising of Office block, Science block and Commerce
block is in 5 km area campus.
As a network expert, you need to suggest the network plan as per (i) to (v) to the authorities keeping in mind the
distance and other given parameters.

Expected wire distance between various locations.


Office Block to Science Block 90 m
Office Block to Commerce Block 80 m
Science Block to Commerce Block 15 m
Kolkata Admission Office to Ana Nagar Campus 450 km
Expected number of computers to be installed at various locations in the university are as follows:
Office Block 10
Science Block 140
Commerce Block 30
Kolkata Admission Office 8
(i) Suggest the authorities, the cable layout amongst various blocks inside university campus for connecting the
blocks.
(ii) Suggest the most suitable place (i.e. block) to house the server for this university with a suitable reason.
(iii) Suggest an efficient device from the following to be installed in each of the block to connect all the computers.
(a) Modem (b) Switch (c) Gateway
(iv) Suggest a suitable topology to connect the computers in each building.
(v) University is planning to connect its campus in Kolkata which is more than 100 km. Which type of network will
be formed?

32. (a) Underline the syntax errors in the following program


x = int(input(“Enter first number:))
y = int(input(“Enter second number:”))
z = int(input(“Enter third number:”)
a = x+ b+ z
print (“Result = ”, b)
(b) Write the code to create the following table Student with the following fields
RollNo FirstName LastName Address ContactNo
ContactNo Marks Course Rank
In the table, Rank should be Good, Best, Bad, Worst, Average.
 o
(a) Differentiate between a logical error and syntax error. Also, give suitable examples of each in Python.
(b) What is the use of fetchone() method? Write an example code to fetch a single record from a database.
Note :
Database : PythonDB
Table : Student
Host : localhost
UsedlD : root
Password : arihant

33. Which module is used to operate on CSV file?


Write a python program with following functions :
(a) addcsv():
File old.csv has come from branch in Pune and it needs to be added to file “updated.csv” which has data for all
branches. Write the code in the function to perform the same.
(b) convertcsv() :
A file old.csv has come with separator ‘:’ but your system can only read ‘;’ Write a program to convert to
“converted.csv” file. Write the function to change the separator of the file.
 o
CSV files are opened with which argument to suppress EOL translation. Write a python program to perform the
following using functions as follows :
(a) copytocsv() :
A CSV file “marks.csv” has name, class and marks separated by comma. Write the Python function to copy only
the name and class to another CSV file “class.csv”.
(b) copyselected() :
The CSV file “marks.csv” which has name, class and marks separated by comma. Write the Python function to
copy only rows of students of class 2 to another CSV file “class.csv”.

Section E
34. Consider the following table Person
P_Id LastName First Name Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
4 Nilsen Johan Bakken 2 Stavanger
(i) What should be the constraint(s) of the P_Id column?
(ii) If 3 columns are added to the table , what will be its degree?
(iii) Write statements to :
(a) Display the Unique Cities.
(b) Display Firstnames of people who do not have a address.
 (Option for part (iii) only)
o
Write appropriate data types to store the following :
(a) Amounts carrying values with decimal.
(b) Joining dates.

35. The code given below reads a text file and displays those words that begin with an uppercase vowel and end with a
lowercase vowel . Some of the codes are missing .Write codes to fill up the blanks.
f=open(“emp.txt”)
filedata=f.read()
count=0
print(filedata)
data=filedata.split(‘ ’)
for.......... in data : #Blank1
if words[–1] in “aeiou” and ...in “AEIOU”: # Blank2
print(......... .) # Blank3
f.close()
(i) Write the missing code for Blank1.
(ii) Write the missing code for Blank2.
(iii) Write the missing code for Blank3.

 EN
Page 1 NODIA Sample Paper 6 Computer Science Class 12

Sample Paper 6
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A
1. The output of the code will be :
L=[6,7,8,9,10]
print(L[2:20])
(a) [8, 9, 10] (b) [ ]
(c) Error (d) [6,7,8,9,10]

2. The random function returns a random value between


(a) 1 and 10 (b) 0 and 10
(c) 0 and 1 (d) 1 and 100

3. To read three characters from a file object f, we use..........


(a) f.read(3) (b) f.read()
(c) f.readline() (d) f.readlines()

4. State True or False


“The pop() method removes and displays the last element of a list.”

5. ............are drawn using certain special purpose symbols.


(a) Algorithm (b) Pseudocode
(c) Flowchart (d) Decision table

6. To arrange a table in descending order of field Salary the clause to be used is


(a) Order by Salary (b) Order by Salary Desc
(c) Arrange by SalaryDesc (d) Arrange by Salary

7. The BETWEEN clause can not be used for


(a) Integer Fields (b) Varchar Fields
(c) Date Fields (d) None of these
8. The constraint that ensures that the field does not get any NULL values is
(a) NULL (b) PRIMARY KEY
(c) CHECK (d) NOT NULL

9. is and is not are_____Operators.


(a) Membership (b) Identity
(c) Logical (d) Comparison

10. What will the following code display?


name = “Neha”
type (name)
(a) Invalid function <type>
(b) <class ‘str’>
(c) <class ‘int’>
(d) <class ‘float’>

11. Which of the following is not required while specifying the connection string in database connection?
(a) Host (b) Table name
(c) Username (d) Password

12. The ALTER TABLE command belongs to.............category


(a) DML (b) TCL
(c) DDL (d) DCL

13. Which of the following are possible relational operations?


(a) Join (b) Selection
(c) Cartesian product (d) All of these

14. Given a tuple tup = (20,50,10,60,30). The statement append(90) returns


(a) (20,50,10,60,30,90) (b) (90)
(c) Error (d) (30,90)

15. To open a text file for adding records keeping the existing records the mode should be
(a) ab (b) xb
(c) rb (d) w+

16. A device that connects two dissimilar networks is


(a) Modem (b) Repeater
(c) Bridge (d) Gateway

Directions : (Q.Nos. 17-18) are Assertion and Reason based questions.

17. Assertion (A) Binary files are processed faster than text files.
Reasoning (R) They are written in Binary format and are more close to the computer.
(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.
18. Assertion (A) A function that is neither built in nor modular must be defined.
Reason (R) The code of built in and modular functions are available for the Python compiler , but if the function is
not defined anywhere the compiler cannot get the code.
(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.

Section B
19. Observe the code given below and find the output.
s=“OceanView”
print(s[8] +s[2:] +str(len(s)))

20. What is the purpose of switch in a network?


 o
Write names of few network devices.

21. (a) What is the output of below questions?


l1 = [23, 45, 19, 77, 10, 22]
(i) l1.sort()
(ii) max(l1)
(b) Find error in defination of the function given.
def finderrors(x=20,y)
print(x+y*2)

22. List some commonly used DBMS software packages.

23. (a) Write the full forms of


(i) HTML
(ii) HTTPs
(b) Write any two advantages of tree topology.

24. What output will the following code produce?


empdict={‘Eno’:[1,2,3,4], ‘Ename’ : [‘Raj’, ‘Seema’, ‘John’, ‘Smith’],
‘Sal’:[10000, 20000, 30000, 40000]}
print(empdict[‘Ename’][0], empdict[‘Sal’][0])
 o
Write any two differences between Dictionary and Tuple.

25. Mention atleast three limitations of DBMS.


o
What are primary and alternate key in a database? Give suitable example to explain each.
SECTION C
26. Consider the tables Hotel and Room given below :
Table : Hotel
TId CName Roomld DtofArrival Charges
T1 Ritesh R1 2016-09-09 1800
T2 Sumana R2 2020-08-01 2000
T3 Abhi R3 1995-04-05 3000
T4 Ram R1 1994-02-02 2500
T5 Nitin R2 NULL 7000

Table : Room
RoomlD RoomType FLoor
R1 AC First
R2 Deluxe Second
R3 General Second
(a) Write a command to display the customer names and the types of rooms in which they are staying.
(b) With respect to the tables given above, write SQL commands for the following.
(i) Create the table hotel and insert the 1st record
(ii) Display the details of customers who have arrived after 01-05-2005
(iii) Display names and room types of customers whose charges are between 2000 and 3000.
(iv) Display Names of customers who are staying in “AC” rooms”

27. A binary file “data.dat” contains records of students as per following structure :
Ano Sname Marks
1 Raj 850
h
h
Write a Program in Python to search for a student whose number/id is input by the user. If not found appropriate
message should be displayed.
 o
Write a program with method countand ( ) to count the word ‘and’ or And’ as an independent word in a text file
“status.txt”. e.g. if the content of the file “status. txt” is as follows:
Welcome to your one-step solutions for all your study, practice and assessment needs for various competitive &
recruitment examinations and school segment. We have been working tirelessly for over a decade to make sure that
you have best in class study resources because you deserve SUCCESS AND NOTHING LESS...
Then the output of the program should be: Count of _and_ in file is/are: 3
Page 5 NODIA Sample Paper 6 Computer Science Class 12

28. (a) Write the SQL commands for (i) to (iv) on the basis of the table HOSPITAL
TABLE: HOSPITAL
No Name Age Department Date-ofadm Cha-rges Sex
1 Sandeep 65 Surgery 23/02/98 300 M
2 Ravine 24 Orthopaedic 20/01/98 200 F
3 Karan 45 Orthopaedic 19/02/98 200 M
4 Tarun 12 Surgery 01/01/98 300 M
5 Zubin 36 ENT 12/01/98 250 M
6 Ketaki 16 ENT 24/02/98 300 F
7 Ankita 29 Cardiology 20/02/98 800 F
8 Zareen 45 Gynaecology 22/02/98 300 F
9 Kush 19 Cardiology 13/01/98 800 M
10 Shailya 31 Nuclear Medicine 19/02/98 400 M
(i) To show all information about the patients of Cardiology Department.
(ii) To list the name of female patients, who are in Orthopaedic Department.
(iii) To list names of all patients with their date of admission in ascending order.
(iv) To display Patient’s Name, Charges, Age for male patients only.
(b) Write the command to view all the tables in database.

29. Write user defined functions factors(num) and factorial(num) to find the factors and factorial of a number accepted
from the user and passed to the functions from main function.

30. Write the Push operation of stack containing person names. Notice that the name should only accept characters,
spaces and period(.) except digits. Assume that Pname is a class instance attribute.
 o
Find the final contents of a stack that encounters the following tokens.
Assume that an operand is pushed to stack and a binary operator pops two operands from stack and pushes the result
to the stack.
45, 30, + , 50, 80, +, +

Section D
31. Quick Learn University is setting up its academic blocks at Prayag Nagar and planning to set up a network. The
university has three academic blocks and one human resource Centre as shown in the diagram below:
Centre to Centre distance between various blocks/Centre is as follows:
Law Block to Business Block 40 m
Law Block to Technology Block 80 m
Law Block to HR Centre 105 m
Business Block to Technology Block 30 m
Business Block to HR Centre 35 m
Technology Block to HR Centre 15 m
Number of computers in each of the blocks/centre are as follows:
Law Block 15
Technology Block 40
HR Centre 115
Business Block 25
(i) Suggest the most suitable place (i.e. block/Centre) to install the server of this university with a suitable reason.
(ii) Suggest an ideal layout for connecting these block/Centre for a wired connectivity.
(iii) Which device you will suggest to be placed/installed in each of these blocks/Centre to efficiently connect all the
computers with in these blocks/Centre ?
(iv) The university is planning to connect its admission office in the closest big city, which is more than 250 km from
university, which type of network out of LAN, MAN or WAN will be formed? Justify your answer.
(v) Expand the following
LAN
WAN

32. (a) Underline the errors in the following code and write the correct code :
while s>0
if a%2=0
print(a%2)
elseif a%3=0 then
print(a%3)
(b) What is database connectivity? How to create a connection object?
 o
(a) Differentiate between identifier and keyword.
(b) What conditions or terms are included by BD-API?

33. What does csv writer() function do?


Write a python program for operating on a csv file “people.csv” using following functions :
(a) addPeople() :To input details of people and add them to a csv file “people.csv” without removing the previous
records. The record structure is as follows :
AdhrNo Name City Age
The file should store only those people whose age is greater than and equal to 18.
(b) getPeople() : To open the file “people.csv” and display records whose name starts with “P”
 o
What is the use of writerow() function?
A file “Toys.csv” exists storing details of toys as per following structure :
ToyID Toyname Category Cost
Write a program in python with functions as follows
(a) addToy() : To append data of toys and store them to the file “Toys.csv” only if the Toy category is “Boys”.
Also display the number of toys added.
(b) showToys() : To open the file “Toys.csv” and display records of toys whose cost is above 1000.

Section E
34. Consider the following table Cab :
Table : Cab
CablD CabType Nop Rate
Cb1 Sedan 4 40
Cb2 Yellow Taxi 5 25
Cb3 Mini 3 30
Cb4 Micro 2 20
(i) Which column qualifies to be the primary key?
(ii) Write a command to display the fields of the table along with their types and sizes.
(iii) Write statements to :
(a) Add a new column Driver varchar(30)
(b) Change data type of Rate column to float(6,1).
(Option for part (iii) only)
(a) To display the cab type whose rate is more than 25.
(b) To display cab id and Number of passengers for cab sedan.

35. Riya wrote a program to search any string in text file “school”. Help her to execute the program successfully.
def check () :
datafile = open (.....)
found = input (“Enter any string to
be searched : ”)
f = False
for line in ....... :
if found in line :
f = .......
break
return f
f = check ()
if (f = =.......) :
print (“True”)
else :
print (......)
(i) Riya should open which file to search any string?
(ii) Which value will assign to f in Line 7?
(iii) Fill the blank in Line 5.

 EN
Page 1 NODIA Sample Paper 7 Computer Science Class 12

Sample Paper 7
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A

1. Which of the following functions write data to a binary file?


(a) pickle() (b) writer()
(c) load() (d) dump()

2. _____can be create using cursor( ) method of connection object.


(a) Cursor object (b) Cursor variable
(c) Connect (d) None of these

3. _____command displays the contents of a table.


(a) DISPLAY (b) VIEW
(c) SELECT (d) SHOW

4. State True or False


Integer is a mutable data type in Python.

5. Identify the output of the following Python statement:


b = 1
for a in range(1, 10, 2):
b += a + 2
print(b)
(a) 31 (b) 33
(c) 36 (d) 39

6. Which of the following Python function displays the memory id of a variable?


(a) type( ) (b) str( )
(c) getid( ) (d) id( )
7. Which of the following is an advantage of SQL?
(a) High speed (b) Client/Server language
(c) Easy to learn (d) All of these

8. Which of the following operator performs an integer division?


(a) * (b) //
(c) / (d) **

9. Predict the output of the following program:


a = 5
b = a = 15
c = (a < 15)
print (“a = ”, a)
print (“b = ”, b)
print (“c = ”, c)
(a) a=15 (b) a=15
b=15 b=10
c=False c=True
(c) a=15 (d) None of these
b=None
c=False

10. Given s=“AISSE@2023”. What will be the output of print(s[-1: :-1])?


(a) ‘3202@ESSIA’ (b) 3
(c) AISSE (d) ESSIA

11. A primary key of a relation must be_____.


(a) UNIQUE only (b) NOT NULL only
(c) Both UNIQUE and NOT NULL (d) Neither UNIQUE nor NOT NULL

12. The........clause can group records on the basis of common values in a field.
(a) AGGREGATE (b) GROUP
(c) GROUP BY (d) JOIN

13. The python function that adds a list at the end of another list is
(a) join() (b) add()
(c) append() (d) extend()

14. Which of the following functions will read entire contents of a text file?
(a) read() (b) readfull()
(c) readline() (d) readfile()

15. The cross join is also called


(a) Merging (b) Cartesian product
(c) Natural join (d) Equi join
16. ______is the base protocol for all application protocols.
(a) FTP (b) TCP/IP
(c) IRCP (d) Telnet

Direction : (Q.Nos. 17-18) are Assertion and Reason based questions.

17. Assertion (A)Pickling is a way to convey a Python object into character stream.
Reason (R) To perform pickling, the pickle module needs to be imported.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true. A.

18. Assertion (A) A recursive function does not require a loop.


Reason (R) A recursive function calls itself again and again until a certain condition is true.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.

Section B
19. Observe the code given below and find the output :
s= “oceanview”
count=0
for a in s:
if a in “stuv”:
count+=1
print(count)

20. What is the difference between video conferencing and chat?


 o
What is WWW?

21. (a) Given the following code :


d={‘Bed’:145000, ‘Almirah’:9000,
‘Chair’:1000}
for v in d.keys():
if d[v]>100000:
d[v]– =10000
print(d)
What will be the output of the print statement?
(b) Write the value stored in the variable Num by each of the following statements.
(i) Num = 2 * 3 – 4
(ii) Num = 2+3–1*3
(iii) Num = (2+3)*2
22. Explain database and DBMS in detail.

23. (a) Write the full forms of :


(i) RJ45 (ii) XML
(b) Write one advantages of Bus topology compared to Star and one advantage of star topology compared to Bus.

24. What output will the following code produce?


y=str(123)
x= “hello”*3
print(x,y)
x=“hello” + “world”
y=len(x)
print(y,x)
o
Write function names for the following with respect to strings.
(i) To make the first letter of a string in capital
(ii) To find the index of the 1st occurrence of a string in another

25. What is DDL? Explain with its commands.


 o
What is DML? Explain with its commands.

Section C
26. (a) Consider the following tables PERSON and ORDERS
Table : PERSON
P_Id Last_Name First_Name City

1 Sharma Abhay Mumbai


2 Gupta Mohan Delhi

3 Verma Akhil Mumbai

Table : ORDERS
O_Id Order_No P_Id
1 10050 3
2 25000 3
3 5687 1
4 45000 1
5 35000 15
With respect to the tables given above write a command to display the Lastname, Firstname and corresponding
order number arranged by Lastname.
(b) With respect to the table PAYMENTS given below, write, output of the following questions.
TABLE : PAYMENTS
Empld Emp_Name Salary Department
1 Ridhi 20000 D1

2 Rohit 25000 D2

3 Rakesh 20000 D2

4 Roshan 44000 D1

5 Rohini 15000 D3
6 Radha 14000 D1

(i) To display the average of employees salary from PAYMENTS table.


(ii) To count the total number of employees from PAYMENTS table Department wise
(iii) To count distinct values of column Department from PAYMENTS table.
(iv) To display department wise number of employees , but for only those departments where number of employees
are more than 2.

27. Write a code in Python to open a Binary file “College.dat” containing records of students as per following structure:
Roll Name SemPercentage
The code should display only records of students from the file where the percentage is greater than 30.
 o
Write a method countopen( ) to count and display the number of lines starting with the word ‘OPEN’ (including
lower cases and upper cases) present in a text file “start. txt”.
e.g. If the file “start.txt” contains the following lines:
Get the data value to be deleted,
Open the file for reading from it.
Read the complete file into a list
Delete the data from the list
Open the file
Open same file for writing into it
Write the modified list into file.
Close the file.
The method should display
Total lines started with word ‘OPEN’ is/are: 3
28. (a) Write SQL commands from (i) to (iv) on the basis of the table INTERIORS given below
TABLE : INTERIORS

No ITEMNAME TYPE DATEOF- PRICE DISC-OUNT


STOCK

1 Red rose Double Bed 23/02/02 32000 15

2 Soft touch Baby cot 20/01/02 9000 10

3 Jerry’s home Baby cot 19/02/02 8500 10

4 Rough wood Office Table 01/01/02 20000 20

5 Comfort zone Double Bed 12/01/02 15000 20


6 Jerry look Baby cot 24/02/02 7000 19
7 Lion king Office Table 20/02/02 16000 20

8 Royal tiger Sofa 22/02/02 30000 25

9 Park sitting Sofa 13/12/01 9000 15

10 Dine Paradise Dining Table 19/02/02 11000 15

11 White Wood Double Bed 23/03/03 20000 20


12 James 007 Sofa 20/02/03 15000 15
13 Tom look Baby cot 21/02/03 7000 10
(i) To show all information about the Sofa from the INTERIORS table.
(ii) To list the ITEMNAME, which are priced at more than 10000 from the INTERIORS table.
(iii) To list ITEMNAME and TYPE of those items, in which DATEOFSTOCK is before 22/01/02 from the
INTERIORS table in descending order of ITEMNAME.
(iv) To insert a new row in the INTERIORS table with the following data
{14, ‘TrueIndian’, ‘Office Table’, ‘25/03/03’, 15000, 20}
(b) Write the command to display the sum of prices of items of type “cot”.

29. Write a user defined function to accept a string and check whether it is palindrome or not.
(A palindrome is a string that is same as its reverse)

30. Explain the traversal operation in a stack.


Write the algorithm for Traversal of a stack to display its contents.
You need not to write the actual code.
 o
Find the final contents of a stack that encounters the following tokens.
Assume that an operand is pushed to stack and a binary operator pops two operands from stack and pushes the result
to the stack.
7,11,*,80,+,50,+
Section D

31. Tech Up Corporation (TUC) is a professional consultancy company. The company is planning to set up their new
offices in. India with its hub at Hyderabad. As a network adviser, you have to understand their requirement and
suggest to them the best available solutions. Their queries are mentioned as (i) to (v) below.
Physical locations of the blocks of TUC

Block to block distances (in metre)


Block (From) Block (To) Distance
Human Resource Conference 60
Human Resource Finance 120
Conference Finance 80
Expected number of computers to be installed in each block
Block Computers
Human Resource 125
Finance 25
Conference 60
(i) What will the most appropriate block, where TUC should plan to install their server?
(ii) Draw a block to block cable layout to connect all the buildings in the most appropriate manner for efficient
communication.
(iii) Write names of different types of Modems.
(iv) Which of the following devices will be suggested by you to connect each computer in each of the buildings?
(a) Gateway (b) Switch (c) Modem
(v) Company is planning to connect its Block in Hyderabad which is more than 20 km. Which type of network will
be formed?

32. (a) Underline the errors in the following code and write the correct code:
s= “WelcometoCS”
For a IN s :
If a IN “aeiou” :
print(a)
else
print(“False”)
(b) Write a code in Python to update the class of a student to 12 whose roll number is 22. The table structure is as
follows :
RollNo Name Class Perc
Note :
Database : PythonDB
Table : Student
Host : localhost
UserId : root
Password : arihant
 o
(a) Write the output of the following function
def showOutput( ):
num=4 + float(7)/int(2.0)
print(“num =”, num)
(b) Write a code in Python to delete the record of a student whose rollno is 33. The table structure is as follows
RollNo Name Class Perc
Note :
Database : PythonDB
Table : Student
Host : localhost
UserId : root
Password : arihant

33. What is the use of writerows() function for CSV files?


A binary file “Hotel.dat” exists storing details of hotel customers as per following structure:
Roomld CustomerName Days
Write a program in python for adding and displaying records from the binary file using following functions
(a) Reserve() : To add data of customers to the binary file.
(b) ShowReservations() : To open the file “Hotel.dat” and display all the records.
 o
What is csv. reader() function?
A binary file “Telephone.dat” exists storing details of BSNL customers as per following structure:
PhoneNo CustomerName ConnType
Write a program in python for adding and displaying record count from the binary file using following functions
(a) NewCustomer() : To add data of customers to the binary file “Telephone.dat”.
Note : The existing connection data should be preserved.
(b) PrintConnections() : To open the file “Telephone.dat” and display the connections and number of connections.

Section E
34. Consider the following table
TABLE : INTERIORS
No ITEMNAME TYPE DATEOF- PRICE DIS-CO-UNT
STOCK
1 Red rose Double Bed 23/02/02 32000 15
2 Soft touch Baby cot 20/01/02 9000 10
3 Jerry’s home Baby cot 19/02/02 8500 10
(i) What should be the data type for the DATEOFSTOCK column?
(ii) Write a command to add a new record as follows :
4, “Morris”,”Sofa Set”
Rest of the field values are not given
(iii) Write statements to :
(a) Write a command to display only the Column ITEMNAME, Net Amount(PRICE-DISCOUNT)
(b) Display only ITEMNAME and Discount column.
(Option for part (iii) only)
(a) Which clause is to be used to search non blank values in the table?
(b) Which command will be used to make the “No” column as the primary key?

35. A program in python to modify records of a binary file “hotel.dat” using random access. The program would accept
the room id , search the record by random access and display. It will then accept the new data and modify the file.
The file structure is :
Roomld Customer Name Days
import pickle
1st=[]
f=open(“hotel.dat”, “rb+”)
ans=‘y’
while ans==‘y’:
r=int(input(“Enter roomid to
modify :”))
1st=pickle.load(f)
size=f.tell()
f.seek(0)
f.seek((r-1)*size)
1st=pickle.load(f)
print(“old record ”)
print(“Room Id :”, 1st[0])
print(“Customer :”, 1st[1])
print(“Days :”, 1st[2])
f.seek(0)
... ... ... # Statement 1
print(“Enter new record ”)
nm=input(“Enter, customer name
:”)
days=input(“Enter days :”)
rs=str(r)
1st=[rs,nm,days]
pickle.dump(1st,f)
ans=input(“Modify another(y/n)”)
f.close()
(i) What type of data is returned by the load() method?
(ii) Which method closes a binary file?
(iii) What will be inserted in statement 1?

 EN
Page 1 NODIA Sample Paper 8 Computer Science Class 12

Sample Paper 8
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A
1. What is the output of the following code?
>>> a = 10
>>> b = 2
>>> print(“Output is”,(a+10*2+b))
(a) Output is 22 (b) Output is 32
(c) Output is None (d) None of these

2. The...............mode opens a file for both reading and writing.


(a) wr (b) rw
(c) r+ (d) a+

3. Give the output for the following program segment given below.
for i in range (-5,-7,-1):
print (i + 1)
(a) -7,-6,-5 (b) -5,-6,-7
(c) No output (d) Error

4. For readline(), a line is terminated by


(a) ‘\n’ (b) EOF
(c) Either (a) or (b) (d) None of these

5. The join operation can join..........tables.


(a) 1 (b) 2
(c) 3 (d) Multiple

6. A table can have maximum..........primary key(s).


(a) 1 (b) 2
(c) 3 (d) Many
7. State True or False
“A tuple is an Editable data store”.

8. Which comments start with # symbol?


(a) Double line (b) Multi-line
(c) Single line (d) All of these

9. A table needs to restrict Salary column values to more than 50000. The constraint that has to be used is
(a) NULL (b) PRIMARY KEY
(c) CHECK (d) NOT NULL

10. To insert a record from Python to a mysql database the...........function needs to be executed.
(a) execute() (b) executeUpdate()
(c) executeQuery() (d) None of these

11. You can repeat the elements of the tuple using which operator?
(a) * (b) +
(c) ** (d) %

12. A table can be sorted by...........fields.


(a) 1 (b) 2
(c) More than 2 (d) None of these

13. A device that connects the network cable to the NIC is


(a) RJ45 (b) Repeater
(c) Hub (d) Switch

14. Which index number is used to represent last character of string?


(a) – 1 (b) 1
(c) 0 (d) n – 1
15. What will be the output of the following code?
a, b = 10, 5
x, y = a + b, b – 2
z = x – y
print (“x:”, x, “y:”, y, “z:”, z)
(a) x: 16 y:3 z:20 (b) x: 15 y:3 z:20
(c) x: 16 y:3 z:12 (d) x: 15 y:3 z:12
16. The...........clause groups records by common values of a column.
(a) BETWEEN (b) ORDER BY
(c) HAVING (d) GROUP BY

Directions (Q. Nos. 17-18) are Assertion and Reason based questions.
17. Assertion (A) Default parameters to a function are not compulsory but are a good practice to specify.
Reason (R) If default parameters are specified the formal parameters will take the default values , if any of the actual
parameters are not passed.
(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.
18. Assertion (A) A recursive function requires a base condition.
Reason (R) The base condition is the one that makes the function exit at a point.
(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.

Section B
19. Predict the output.
(i) ‘wonders’.center(12, ‘*’)
(ii) ‘wonders25’.isalnum( )

20. Identify the types of networks formed in the following cases :


(a) Two friends sharing files between a distance of 1000 km.
(b) A device transmitting voice to stations within a distance of 30 km.
 o
Write names of protocols used in following cases :
(a) A network user downloading a photograph from a server
(b) Two friends chatting over the web.

21. (a) Given the following code :


str1 = input (“Enter the string:”)
final = “”
for i in range(len(str1)):
if (i%2 == 0):
final = final + str1[i]
print(“Modified string is : ”,
final)
What is the above code doing?
(b) Consider the following list and answer the below questions.
l = [6, 9, 8, ‘Hi’, ‘Hello’, 45,
23, ‘New’]
(i) l[4:]
(ii) l[-4]
(iii) l[2:5]
(iv) ‘World’ in l

22. Write few advantages of SQL.

23. (a) Identify whether the following address is a valid IP address or not 256.200.192.1
(b) What is the difference between domain name and IP address?

24. Distinguish between tuple and list.


 o
How can you add following data in empty dictionary?
Keys Values
A One
B Two
C Three
D Four

25. What is equi join ? Explain with an example.


o
Identify which of the functions given below are aggregate functions.
COUNT() , LEFT() , RIGHT() , MAX() , AVG() , TRIM()

Section C
26. (a) Consider the tables EMP and SALGRADE storing details of employees and their salaries.
Table: EMP
empno ename sal date
110 Priya 7000 11-11-2010

111 Seema 14000 15-02-2014

151 Sachin 30000 18-04-2015

142 Deepa 25000 20-05-2015

Table : SALGRADE

empno city lowsal hisal grade

110 Delhi 5000 10000 2


111 NCR 11000 13000 1

142 Meerut 10000 20000 5

With respect to the tables given above write a command to display the Employee names and the corresponding
cities.
(b) With respect to the tables given above , write commands for the following :
(i) To display the average salaries of all employees who are not from Delhi.
(ii) To display, maximum salary from the EMP table among employees whose date is after “2014”
(iii) To find the count of employees who are from “Delhi”
(iv) To display each employee’s name and Grade.

27. Write a method Filterwords() to find and display words from a text file ‘NewsLetter.txt’
whose length is less than 4.
 o
Write a method countAN() that checks the number of occurrance of “A” and “N” in a text file “Story.txt”.
28. (a) Given the following tables for a database LIBRARY
Write SQL commands (i) to (iv) with respect to the tables BOOKS and ISSUED
TABLE: BOOKS
Book_Id Book Name Author_ Publishers Price Type Qty
Name
F0001 The Tears William First Publ 750 Fiction 10
Hopkins
F0002 Thunder Anna First Publ 700 Fiction 5
bolts Roberts
T0001 My First Brain & EPB 250 Text 10
C++ Brooke
T0002 C++ A.W. TDH 325 Text 5
Brainworks Rossaine
C0001 Fast Cook Lata Kapoor EPB 350 Cookery 8

TABLE : ISSUED
Book_Id Quantity_Issued
F0001 3
T0001 1
C0001 5
(i) To show Book name, Author name and Price of books of EPB Publishers.
(ii) To list the names from books of Fiction type.
(iii) To display the names and price of the books in descending order of their price.
(iv) To increase the price of all books of First Publ Publishers by 50.
(b) Write the command to remove all the records of the BOOKS table keeping the structure.

29. Write user defined function patterns (n) to display the following pattern for n lines , as per the number passed to the
function. The number to be input in main() function.
Example :
Enter a number : 6
6
66
66 6
66 66
66 666
66 6666
Enter a number :7
7
77
777
7777
77777
777777
7777777
30. A linear stack called status contains the following information :
Phone number of Employee
Name of Employee
Write the following methods to perform given operations on the stack status :
(i) Push_element ( ) To Push an object containing Phone number of Employee and Name of Employee into the
stack.
(ii) Pop_element ( ) To Pop an object from the stack and to release the memory.
 o
Write a function to pop an element from a stack “s” using a function stackpop().

Section D
31. G.R.K International Inc. is planning to connect its Bengaluru Office Setup with its Head Office in Delhi. The
Bengaluru Office G.R.K. International Inc. is spread across an area of approx. 1 square kilometres consisting of 3
blocks. Human Resources, Academics and Administration. You as a network expert have to suggest answers to the
questions (i) to (v) raised by them.
Note Keep the distances between blocks and number of computers in each block in mind, while providing them the
solutions.

Shortest distances between various blocks


Human Resources to Administration 100 m
Human Resources to Academics 65 m
Academics to Administration 110 m
Delhi Head Office to Bengaluru Office Setup 2350 km
Number of computers installed at various blocks
Block Number of Computers
Human Resources 155
Administration 20
Academics 100
Delhi Head Office 20
(i) Suggest the most suitable block in the Bengaluru Office Setup to host the server. Give a suitable reason with
your suggestion.
(ii) Suggest the cable layout among the various blocks within the Bengaluru Office Setup for connecting the blocks.
(iii) Suggest the placement of switch.
(iv) Suggest the most suitable media to provide secure, fast and reliable data connectivity between Delhi Head
Office and the Bengaluru Office Setup.
(v) Expand the following
WAN
LAN

32. (a) Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between
200 and 300 (both included).
(b) Consider the table Faculty whose columns’ name are
F_ID, Fname, Lname, Hire_date,
Salary, Course_name
Write the code to insert the following record into the above table.
101 Riya Sharma 12-10-2004 35000 Java Advance
102 Kiyaan Mishra 3-12-2010 28000 Data Structure
 o
(a) Which of the following are invalid, names and why?
(i) PaidInterest (ii) S-num
(iii) Percent (iv) 123
(b) What is the utility of fetchall() method? Write a code to fetch all the records of a Student table from PythonDB
Database.
Note :
Host : localhost
Database : PythonDB
User : root
Password:arihant
Table : Student

33. Which file can be opened with notepad as well as MS Excel?


A CSV file “Garment.csv” file exists containing records of different types of garments as per following structure.
GarmentlD Type Gender Cost
Write a python program to add and search records of garments from the csv file and display using the following
functions :
(a) AddGarment() : Function to input details of garments and store them to the file “Garment.csv”, if the garment
type is “cotton” or “silk”.
(b) ShowGarments() : To open the file “ Garment.csv”, display details and number of “silk”.garments
 o
What is with statement in Python?
A csv file “cricket.csv” exists to store data of cricketers as follows:
CID CricketerName Strikerate WorldRank
Write a program in python to add data of more cricketers along with the existing records . Also display the details
of cricketers as per the condition given using the functions given:
(a) AppendCricketer() : To accept data of cricketers and append them to the file “cricket.csv”
(b) GetCricketers() : To open the file “Cricket.csv” and display number of cricketers whose world ranking is above
50.
Section E
34. Consider the following table
TABLE : PATIENTS
No Name Age Department Dateofadm Charges Sex
1 Ketaki 16 ENT 24/02/98 300 F
2 Ankita 29 Cardiology 20/02/98 800 F
3 Zareen 45 Gynaecology 22/02/98 300 F
4 Kush 19 Cardiology 13/01/98 800 M
5 Shailya 31 Nuclear Medicine 19/02/98 400 M
(i) What would be the width of Dateofadm field?
(ii) Write commands to remove the records of “Cardiology” department.
(iii) Write statements to :
(a) Display a report showing Name, charges and discount (15%) for all patients.
(b) Display names of female patients .
 (option for part (iii) only)
o
(a) Which function will find the total charges of all patients?
(b) Name the constraint that will restrict duplicate values in Name column.

35. A user defined method to open a text file “para.txt” and display count of number of ‘c’ or ‘C’ and number of ‘e’ or
‘E’ separately.
def test():
f=open(“Para.TXT”)
n1=0
n2=0
while True:
1=........... //Statement
if not 1:
break
for i in 1:
if (i ==‘E’ or i ==‘e’):
n1=n1+1
elif(i==‘C’ or i==‘c’):
n2=n2+1
print(n1)
print(n2)
f.close()
(a) Which module needs to be imported to use text file handling functions?
(b) Write the functionname to close a file object.
(c) Write the code best suitable for statement as marked.

 EN
Page 1 NODIA Sample Paper 9 Computer Science Class 12

Sample Paper 9
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A

1. The alternate to math.pow() function is______operator.


(a) ** (b) c $
(c) + = (d) /

2. Two relations are joined using a common field called______


(a) Alternate key (b) Foreign key
(c) Candidate key (d) None of these

3. To print all elements of tuple in reverse order using______.


(a) [: – 1] (b) [: : – 1]
(c) [1 : : ] (d) [: : 1]

4. Given : s=“Olympic@gmail.com”. What will be the output of print(s[2: :2])?


(a) ‘ypcalcm’ (b) ‘ypcgalcm’
(c) ‘ypcglcm’ (d) ‘pcgalm’

5. State True or False


“A tuple is a immutable data type.”

6. Which of the following Python functions do not require importing of a module?


(a) type() (b) input()
(c) sqrt() (d) Both (a) and (b)

7. Which of the following modes open a text file, such that the new data is written in it keeping the existing contents ?
(a) r+ (b) rw+
(c) w+ (d) a
8. The_____clause with the update command specifies the attribute to be modified.
(a) FIELD (b) ATTRIBUTE
(c) CHANGE (d) SET

9. Which of the following refers to a small, single site network?


(a) DSL (b) RAM
(c) WAN (d) PAN

10. Write the output of given code:


s1 = ‘Hello’
s2 = ‘World’
s = s1 + s2
print(s)
(a) Hello World (b) HelloWorld
(c) ‘Hellow’ ‘World’ (d) Error

11. The_____clause with GROUP BY, can filter groups from the query output.
(a) WHERE (b) FILTER
(c) HAVING (d) CHECK

12. Given a list L= [6,12,9,40,2,1]. Which of the following statements will arrange the list in reverse order
(a) L.arrange()
(b) L.sort()
(c) L.sort(reverse=True)
(d) L.sort(reverse=False)

13. Which method returns the next row from the result set as tuple?
(a) fetchone( ) (b) fetchmany( )
(c) fetchall( ) (d) rowcount

14. An alternate key can be


(a) only 1 in a table. (b) a table can have maximum 2 alternate keys.
(c) a table can have at most 3 alternate keys. (d) multiple in a relation.

15. Which statement of SQL provides statements for manipulating the database objects?
(a) DDL (b) DML
(c) DCL (d) TCL

16. Which attribute is used to return access mode with that file was opened?
(a) file.mode (b) mode.file
(c) file*mode (d) None of these

Directions : (Q. Nos. 17 and 18) are Assertion and Reason based questions.
17. Assertion (A) A python function can return more than one value to the calling function.
Reason (R) The return statement takes only a list as parameter.
(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.

18. Assertion (A) While opening a binary file the mode may not be specified.
Reason (R) The open function for file opening by default takes the mode parameter as ‘rb’ for binary files, if no
mode is specified.
(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
19. Find the output of the following code :
i=1
while(i<5):
print(i)
i = i*2

20. Give one suitable example of each URL and domain name.
 o
Can we use URL to access a web page? How?

21. (a) Correct the error if any in the following statement.


(i) a + 5 = b
(ii) 1 = 2b + c * d
(iii) name = Aryan
(iv) a = 20
print a;
(b) Evaluate the following expression
If a = b = 10, c = 5
a = b*3//4 + c//4 + 4– b + 5//6

22. Define UPDATE command of SQL with its basic syntax and also give one of its example.

23. (a) Write any two characteristics of IP address.


(b) What is VoIP?

24. Write the one example of following terms.


(i) Identifier (ii) Punctuator
(iii) Keyword (iv) Constant
 o
What will be the output of the following code?
a, b = 10, 5
x, y = a + b, b – 2
z = x – y
print (“x:”, x, “y:”, y, “z:”, z)

25. Expand the following abbreviation :


(i) SQL (ii) DML
(iii) DDL (iv) TCL
 o
Mention two characteristics of SQL.

Section C
26. Consider the following tables PRODUCT and CLIENT
TABLE : PRODUCT
PID ProductName Manufacturer Price
TP01 Talcom Powder LAK 40
FW05 Face Wash ABC 45
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120
FW12 Face Wash XYZ 95

TABLE : CLIENT
C_ID ClientName City P_ID
01 Cosmetic Shop Delhi FW05
06 Total Health Mumbai BS01
12 Live Life Delhi SH06
15 Pretty Woman Delhi FW12
16 Dreams Bengaluru TP01
(a) To display the ClientName, City from table CLIENT and ProductName and Price from table PRODUCT, with
their corresponding matching P_ID.
(b) Write SQL queries for statements (i) to (iv)
(i) To display the details of those Clients, whose City is Delhi.
(ii) To display the details of products, whose Price is in the range of 50 to 100 (both values included).
(iii) To display product name and their manufacturer whose Price is more than 100.
(iv) To display client name for those whose product id is FW12.

27. Define a function in Python to accept a sentence and count the number of occurrences of the word “is” and “was”.
Example
Input : “He is a good boy. She was and is a good girl”
Output :
No. of is : 2
No. of was : 1
 o
Write a definition of a function that takes input a sentence and display the list of words that start with a lowercase
vowel and list of words that start with a uppercase vowel separately.
Example
Input : A quick black elephant enters Into a jungle.
Output
List of words starting with lowercase vowels [‘elephant’, ‘enters’, ‘a’]
List of words starting with uppercase vowels [‘A’, ‘Into’]

28. (a) Write SQL commands (i) to (iv) for the following tables :
TABLE : STUDENT
S NO NAME STREAM FEES AGE SEX AID
1 ARUN KUMAR COMPUTER 750.00 17 M A1
2 DIVYA JENEJA COMPUTER 750.00 18 F A2
3 KESHAR MEHRA BIOLOGY 500.00 16 M A2
4 HARISH SINGH ENG. DR 350.00 18 M A1
5 PRACHI ECONOMICS 300.00 19 F A3
6 NISHA ARORA COMPUTER 750.00 15 F A3
7 DEEPAK KUMAR ECONOMICS 300.00 16 M A1
8 SARIKA VASWANI BIOLOGY 500.00 15 F A1

TABLE: ADDRESS
AID City
Al Jamshedpur
A2 Kolkata
A3 Mumbai
(i) List the name of all the students, who have taken stream as COMPUTER.
(ii) To count the number of female students.
(iii) To display the number of students stream wise.
(iv) To display names of the students with corresponding cities.
(b) Write the command to display all the tables in the database.

29. Write a program to calculate the sum and mean of the elements which are entered by user.

30. Write the Push operation of stack containing person names. Notice that the name should only accept characters,
spaces and period (.) except digits. Assume that Pname is a class instance attribute.
 o
Find the final contents of a stack that encounters the following tokens.
Assume that an operand is pushed to stack and a binary operator pops two operands from stack and pushes the result
to the stack.
100,8,3,*,50,2,+,+,*
Section D

31. Expertia Professional Global (EPG) in an online corporate training provider company for IT related courses. The
company is setting up their new campus in Mumbai. You as a network expert have to study the physical locations
of various buildings and the number of computers to be installed. In the planning phase, provide the best possible
answers for the queries (i) to (v) raised by them.
Physical locations of the buildings of EPG

Building to building distance (in metre)


From To Distance

Administrative Building Finance Building 60


Administrative Building Faculty Studio Building 120

Finance Building Faculty Studio Building 70

Expected computers to be installed in each building


Buildings Computers

Administrative Building 20
Finance Building 40
Faculty Studio Building 120

(i) Suggest the most appropriate building, where EPG should plan to install the server.
(ii) Suggest the most appropriate building to building cable layout to connect all three buildings for efficient
communication.
(iii) Which type of network out of the following is formed by connection the computers of these three buildings?
(a) LAN (b) MAN (c) WAN
(iv) Write the difference between LAN and MAN.
(v) Expand the following
(a) WAN (b) MAN

32. (a) Write a Python program to find maximum and minimum elements in a tuple.
(b) Consider the table MobileStock with following fields
M_Id, M_Name, M_Qty, M_Supplier
Write the Python code to fetch all records with fields M_Id, M_Name and M_Supplier from database Mobile.
o
(a) Which of the following are invalid names and why?
(i) Paidlnterest (ii) S-num
(iii) Percent (iv) 123
(b) Write the steps for Database connectivity with short explanation of each step.

33. What does tell() method do?


(a) AddRegistration() :To accept more student registration data and store them to the binary file keeping the existing
registration data.
A Binary file “Registration.dat” exists storing details of students who have been registeredfor CBSE board
exams. The file stores following data of students :
RegnNo StudName class No of subjects
(b) CountRegistrations() : Display count of registrations using the functions.
 o
What does seek() method do?
(a) PutBike() : To accept data of more bikes and store them to the file “Bikes.csv”
A CSV file “Bikes.csv” stores details of bikes with their brand names, cc and cost.
Record structure of “Bikes.csv”
BID Bname Brand Cost
(b) SearchBike(bikeid) : To open the file “Bikes.csv” and display details of the bike whose from id is supplied as
the parameter to the function.

Section E

34. Consider the following table ORDERS :


TABLE : ORDERS
O_Id OrderDate OrderPrice Customer
1 2008/11/12 1000 Hansen
2 2008/10/23 1600 Nilsen
3 2008/09/02 700 Hansen
4 2008/09/03 300 Hansen
5 2008/08/30 2000 Jensen
6 2008/10/04 100 Nilsen
(i) Write a statement to create the above table.
(ii) Write a command to change the width of Customer column to varchar(30)
(iii) Write statements to :
(a) Display the field names, their type , size and constraints .
(b) Display details of orders where orderprice is in the range 500 to 1500
 (Option for part iii only)
o
(a) Write a command to increase orderprice of all orders by 15%.
(b) Name the constraint that will restrict both NULL and DUPLICATE values in the O_Id field.
35. A user-defined method to open a text file “para.txt” and write its contents to another file fter removing the 3rd line
def Func():
with open (‘Para.txt’, ‘r’) as f:
l=f.readlines()
f.close()
print(l)
del l[3]
print(l)
f=open (‘Para.txt’, ‘w’)
f...........
f.close()
(a) Which module needs to be imported to use operating system functions like rename() and remove().
(b) Write the function name to open a text file.
(c) Fill the blank as marked in above code.

 EN
Page 1 NODIA Sample Paper 10 Computer Science Class 12

Sample Paper 10
Computer Science (083)
CLASS XII 2023-24
Time: 3 Hours Max. Marks: 70
General Instructions:
1. Please check this question paper contains 35 questions.
2. The paper is divided into 4 Sections- A, B, C, D and E.
3. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark
4. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
5. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
6. Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
7. Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
8. All programming questions are to be answered using Python Language only.

Section A
1. The output of print(math.ceil(17.34)) is
(a) 18 (b) 17
(c) 10 (d) 20

2. The...........clause is used in SQL to specify a range of values.


(a) WHERE (b) DROP
(c) BETWEEN (d) RANGE

3. Two friends have connected their computers , but are getting weak signals. Which device need to be used to get
better signals?
(a) Repeater (b) Hub
(c) Switch (d) Modem

4. ______method creates a cursor object while connecting a Python application with a Mysql database.
(a) connection( ) (b) connect( )
(c) cursor( ) (d) None of these

5. The default mode in which a file is opened is


(a) r (b) rw+
(c) w (d) a

6. Which attribute is used to return access mode with that file was opened?
(a) mode.file (b) mode.file.name
(c) file.mode (d) file.mode.type

7. Which of the following is not a DDL command ?


(a) ALTER (b) CREATE
(c) DROP (d) DELETE

8. State True or False


‘A dictionary is ordered by index”.
9. The module required to use the mode function is
(a) math (b) statistics
(c) random (d) Pandas

10. The.........command can be used to remove all records of a table along with the table structure.
(a) DELETE TABLE (b) DROP TABLE
(c) REMOVE TABLE (d) None of these

11. What is the output of the following code?


>>> a = 10
>>> b = 2
>>> print(a + 10 * 2 + b)
(a) 32 (b) 22
(c) 40 (d) 80

12. Which function is used to generate a sequence of numbers overtime?


(a) range() (b) len()
(c) limit() (d) lim()

13. Which of the following symbol is used in Python for comments?


(a) $ (b) @
(c) // (d) #

14. Given a list Lst= [65,182,90,420,20,10]. What will be the correct statement to take out the 3rd element from the list?
(a) Lst.pop(2) (b) L.find(2)
(c) L.pop(–1) (d) L.del(90)

15. The relation between Primary key , Candidate key and Alternate key is
(a) Primary key = Candidate key - Alternate key
(b) Candidate key= Primary key - Alternate key
(c) Alternate key= Primary key+ Candidate key
(d) None of the above

16. The first integrity rule for relational databases ensures that_____
(a) Primary key is unique
(b) Foreign key is unique
(c) Primary key is unique and NOT NULL
(d) There is only one candidate key

Directions (Q.Nos. 17-18) are Assertion and Reason based questions.

17. Assertion (A) User-defined functions must stay in a Python module.


Reason (R) Each user-defined function must stay in a module ,which is linked to a folder where all the user defined
functions of the module stay.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
18. Assertion (A) Python supports addition of data in file , preserving the previous data.
Reason (R) The write mode erases all previous data of a pre-existing file.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.

Section B
19. Write the corresponding Python expression for the following mathematical expression.
(i) z= a/a+ b – d2
(ii) z= x2 + y3

20. Mr. GopiNath Associate Manager of Unit. Nations corporate recently discovered that the communication between
his company’s accounts office and HR office is extremely slow and signals drop quite frequently. These offices are
120 metre away from each other and connected by an Ethernet cable.
(i) Suggest him a device which can be installed in between the office for smooth communication.
(ii) What type of network is formed by having this kind of connectivity out of LAN, MAN and WAN?
 o
Define hub and write its functions and types.

21. (a) Determine which of the following identifiers are valid. If invalid, explain with reason.
(i) name_1 (ii) _SUM
(iii) $Sum (iv) num ^ 2
(b) Find the output of the following code
i=1
while (i<5):
print(i)
i=i*2

22. Differentiate between char(n) and varchar(n) data types with respect to databases.

23. (a) Mention any two advantages of E-mail over conventional, mail.
(b) Mr. Lal owns a factory which manufactures automobile spare parts. Suggest him the advantages of having a
web page for his factory

24. Name the tokens that are available in Python.


 o

Find the syntax error in the following program and underline after correct them.
90 = w
while(w > 60)
print(w)
w = w – 50

25. Explain the use of ORDER BY clause.


 o
What are DDL and DML?
Section C
26. Consider the tables FAMILY and Occupation:
TABLE FAMILY
No Name Female Members Male Members Income Occup-ationId
1 Mishra 3 2 7000 O1
2 Gupta 4 1 50000 O2
3 Khan 6 3 8000 O2
4 Chaddha 2 2 25000 O1
5 Yadav 7 2 20000 O3
6 Joshi 3 2 14000 O2
7 Maurya 6 3 5000 O1
8 Rao 5 2 10000 O3

Table : OCCUPATION
Occupationld Type
O1 Service
O2 Business
O3 Mixed
(a) To display Family name , corresponding occupation and income where male members are more than 2.
(b) Write SQL queries for statements (i) to (iv) based on tables FAMILY and Occupation.
(i) To select all the information of family, whose Occupation is Service.
(ii) To list the name of family, where female members are more than 3.
(iii) To list all names of family with income in ascending order.
(iv) To count the number of family, whose income is less than 10000.

27. Write a method countFile() to count and display the number of lines starting with the word ‘FILE’ (including small
cases and upper cases) present in a text file “start.txt”.
e.g. If the file “start.txt” contains the following lines:
Get the data value to be deleted,
Open the file for reading from it.
Read the complete file into a list
Delete the data from the list
Open the file
Open same file for writing into it
Write the modified list into file.
Close the file.
The method should display
Total lines started with word ‘FILE’ is/are: 0

o
Write definition of a function that takes input a sentence and display the list of words that end with a lowercase
vowel and list of words that end with a lowercase consonant
28. (a) Study the following tables DOCTOR and SALARY and write SQL commands for the questions (i) to (iv).
TABLE: DOCTOR
ID NAME DEPT SEX E X P E R -
IENCE
101 John ENT M 12
104 Smith ORTHOPEDIC M 5
107 George CARDIOLOGY M 10
114 Lara SKIN F 3
109 K George MEDICINE F 9
105 Johnson ORTHOPEDIC M 10
117 Lucy ENT F 3
111 Bill MEDICINE F 12
130 Morphy ORTHOPEDIC M 15

TABLE: SALARY
ID BASIC ALLOWANCE CONSULTATION
101 12000 1000 300
104 23000 2300 500
107 32000 4000 500
114 12000 5200 100
109 42000 1700 200
105 18900 1690 300
130 21700 2600 300
(i) Display NAME of all doctors who are in MEDICINE department having more than 10yrs experience from
the table DOCTOR.
(ii) Display the average salary of all doctors working in ENT department using the tables DOCTOR and
SALARY. SALARY = BASIC + ALLOWANCE.
(iii) Display the minimum ALLOWANCE of female doctors.
(iv) Display the highest consultation fee among all male doctors.
(b) Write the command to change the data type of consultation to double(8,3).

29. Write a program to count the frequency of elements in a list entered by user.

30. Write the Push operation of stack containing person names. Notice that the name should only accept characters,
spaces and period (.) except digits. Assume that Pname is a class instance attribute.

 o

Find the final contents of a stack that encq]lnters the following tokens.
Assume that an operand is pushed to stack and a binary operator pops two operands from stack and pushes the result
to the stack.
(100, 8, 3, *, 50, 2, +, +, *)
Section D
31. Workalot consultants are setting up a secured network for their office campus of Gurgaon for their day-to-day office
and web based activities. They are planning to have connectivity between 3 buildings and the head office situated
in Mumbai.
Answer the questions (i) to (v) after going through the building positions in the campus and other details, which are
given below:

Distance between various buildings


Building GREEN to Building RED 110 m
Building GREEN to Building BLUE 45 m
Building BLUE to Building RED 65 m
Gurgaon Campus to Head Office 1760 km
Number of computers
Building GREEN 32
Building RED 150
Building BLUE 45
Head Office 10
(i) Suggest the most suitable place (i.e. building) to house the server of this organisation. Also, give a reason to
justify your suggested location.
(ii) Suggest a cable layout of connections between the buildings inside the campus.
(iii) Suggest the placement of the following devices with justification :
(a) Switch
(b) Repeater
(iv) Write the use of Modem in a network.
(v) What is the use of firewall in network?

32. (a) Write a Python program to concatenate following dictionaries to create a new one.
d1={‘A’:10, ‘B’:20}
d2={‘C’:30, ‘D’:40}
d3={‘E’:50, ‘F’:60}
(b) Consider the table MobileStock with following fields
M_Id, M_Name, M_Qty, M_Supplier
Write the Python code to fetch all records with fields M_Id, M_Name and M_Supplier from database Mobile.
o
(a) Sohan has a list containing 8 integers as marks of subject Science. You need to help him to create a program
with separate user defined function to perform the following operations based on the list.
(i) Push those marks into a stack which are greater than 75.
(ii) Pop and display the content of the stack.
Simple Input
Marks = [75, 80, 56, 90, 45, 62, 76, 72]
Sample Output
80 90 76
(b) Consider the following table Traders with following fields

TCode TName City

T01 Electronic Sales Mumbai

T03 Busy Store Corp Delhi

T02 Disp House Inc Chennai

Write Python code to display the names of those traders who are either from Delhi or from Mumbai.

33. What is difference between tell() and seek() methods?


A Binary file “lottery.dat” stores details of lottery ticket holders . The file stores the following details :
TicketNo State Type Prizemoney
Write a program using two functions to operate the file data.
(a) AddBuyers(State) : To accept more ticket details and store them into the file only if the ticket is not from state
passed as parameter to the function.
(b) TicketSearch(tid) : To open the file “lottery.dot” and display details of the ticket whose id is supplied as the
parameter to the function.
 o
Compare text files and binary files.
A Binary file “car.dat” stores details of cars. The file stores the following details :
CarNo Brand Kms Cost
Write a program using two functions to operate the file data.
(a) AddCardata() : To accept car details and store them into the file “car.dat”
(b) CarReport() : To open the file “car.dat” and display details of the cars who have run more than 100000 kilometres.
Section E
34. Consider the following table FLIGHTS :
TABLE : FLIGHTS
FL_NO STARTING ENDING NO_FLIGHT NO_
STOPS
IC301 MUMBAI DELHI 8 0
IC799 BENGALURU DELHI 2 1
MC101 INDORE MUMBAI 3 0
IC302 DELHI MUMBAI 8 0
AB812 KANPUR BENGALURU 3 1
IC899 MUMBAI KOCHI 1 4
AM501 DELHI TRIVANDRUM 1 5
MU499 MUMBAI MADRAS 3 3
IC701 DELHI AHMEDABAD 4 0
(i) The command to create the table was written as :
Create table FLIGHTS( FL_NO integer, STARTING char(20), ENDING char(30), NO_FLIGHT integer, NO_
STOPS integer);
What is wrong with command ?
(ii) What is the cardinality of the table ?
(iii) Which functions will be used to :
(a) Display total number of flights .
(b) Display number of flights whose FL_NO starts with “IC”
(option for part (iii) only)
Write function names to :
(a) Show the average Number of stops.
(b) Show the maximum number of stops.

35. A user-defined method to open a text file ‘Author.txt” and display the lines that have even number of words.
def evenwords():
f=open(“Author.txt”)
ln=f.readlines()
for line in ln:
linex=............// Statement
if len(linex)%2==0:
print(line)
f.close()
(a) How is readline() method different from readlines() method in Python?
(b) Write the use of the reader object in csv file operations.
(c) Fill the blank as marked statement.

 EN
Sample Paper 11
Computer Science (083)
CLASS XII 2023-24

CLASS: XII MAX MARKS:70


SUBJECT: COMPUTER SCIENCE TIME: 3 HOURS
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in
Q35 against part c only.
8. All programming questions are to be answered using Python Language only
SECTION A
1. State True or False 1
“Python has a set of keywords that can also be used to declare variables”
2. Which of the following is not a valid python operator? 1
a) % b) in c) # d) **
3. What will be the output of the following python dictionary operation? 1
data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)
a) {'A':2000, 'B':2500, 'C':3000, 'A':4000}
b) {'A':2000, 'B':2500, 'C':3000}
c) {'A':4000, 'B':2500, 'C':3000}
d) It will generate an error.
4. 1
print(True or not True and False)
Choose one option from the following that will be the correct output after
executing the above python expression.
a) False b) True c) or d) not
5. Select the correct output of the following python code: 1
str="My program is program for you"
t = str.partition("program")
print(t)
a) ('My ', 'program', ' is ', 'program', ' for you')
b) ('My ', 'program', ' is program for you')
c) ('My ', ' is program for you')
1|Page
d) ('My ', ' is ', ' for you')
6. Which of the file opening mode will open the file for reading and writing in 1
binary mode.
a) rb b) rb+ c) wb d) a+
7. Which of the following statements is True? 1
a) There can be only one Foreign Key in a table.
b) There can be only one Unique key is a table
c) There can be only one Primary Key in a Table
d) A table must have a Primary Key.
8. Which of the following is not part of a DDL query? 1
a) DROP
b) MODIFY
c) DISTINCT
d) ADD
9. Which of the following operations on a string will generate an error? 1
a) "PYTHON"*2
b) "PYTHON" + "10"
c) "PYTHON" + 10
d) "PYTHON" + "PYTHON"
10 _______________ Keyword is used to obtain unique values in a SELECT query 1
. a) UNIQUE
b) DISTINCT
c) SET
d) HAVING
11 Which of the following python statement will bring the read pointer to 10th 1
. character from the end of a file containing 100 characters, opened for
reading in binary mode.
a) File.seek(10,0)
b) File.seek(-10,2)
c) File.seek(-10,1)
d) File.seek(10,2)
12 Which statement in MySql will display all the tables in a database? 1
. a) SELECT * FROM TABLES;
b) USE TABLES;
c) DESCRIBE TABLES;
d) SHOW TABLES;
13 Which of the following is used to receive emails over Internet? 1
. a) SMTP b) POP c) PPP d) VoIP
2|Page
14 What will be the output of the following python expression? 1
print(2**3**2)
a) 64 b) 256 c) 512 d) 32
15 Which of the following is a valid sql statement? 1
. a) ALTER TABLE student SET rollno INT(5);
b) UPDATE TABLE student MODIFY age = age + 10;
c) DROP FROM TABLE student;
d) DELETE FROM student;
16 Which of the following is not valid cursor function while performing database 1
. operations using python. Here Mycur is the cursor object?
a) Mycur.fetch()
b) Mycur.fetchone()
c) Mycur.fetchmany(n)
d) Mycur.fetchall()
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion (A): A variable declared as global inside a function is visible with 1
. changes made to it outside the function.
Reasoning (A): All variables declared outside are not visible inside a function
till they are redeclared with global keyword.
18 Assertion (A): A binary file in python is used to store collection objects like 1
. lists and dictionaries that can be later retrieved in their original form using
pickle module.
Reasoning (A): A binary files are just like normal text files and can be read
using a text editor like notepad.
SECTION B
19 Sameer has written a python function to compute the reverse of a number. 2
. He has however committed a few errors in his code. Rewrite the code after
removing errors also underline the corrections made.
define reverse(num):
rev = 0
While num > 0:
rem == num %10
rev = rev*10 + rem
num = num//10
return rev
print(reverse(1234))

3|Page
20 Mention two differences between a Hub and a switch in networking. 2
.
OR
Mention one advantage and one disadvantage of Star Topology.

21 a) What will be the output of the following string operation. 1


. str="PYTHON@LANGUAGE"
print(str[2:12:2])

b) Write the output of the following code. 1


data = [1,2,4,5]
for x in data:
x = x + 10
print(data)
22 Mention two differences between a PRIMARY KEY and a UNIQUE KEY. 2
.
23 a) Expand the following abbreviations: 1
. i) URL ii) TCP

b) What is the use of VoIP? 1


24 Predict the output of the following python code: 2
. def foo(s1,s2):
l1=[]
l2=[]
for x in s1:
l1.append(x)
for x in s2:
l2.append(x)
return l1,l2
a,b=foo("FUN",'DAY')
print(a,b)

OR
Predict the output of the following python code:
data = [2,4,2,1,2,1,3,3,4,4]
d = {}
for x in data:
if x in d:
d[x]=d[x]+1
else:
d[x]=1
print(d)
4|Page
25 A MySQL table, sales have 10 rows. The following queries were executed on 2
. the sales table.
SELECT COUNT(*) FROM sales;
COUNT(*)
10

SELECT COUNT(discount) FROM sales;


COUNT(discount)
6
Write a statement to explain as to why there is a difference in both the
counts.
OR
What is the difference between a Candidate Key and an Alternate Key
SECTION C
26 a) Consider the following tables Emp and Dept: 1+2
. Relation: Emp
Relation: Dept
empcode ename deptid Salary
deptid dname
1001 TOM 10 10000
10 Physics
1002 BOB 11 8000
11 Chemistry
1003 SID 10 9000
1004 JAY 12 9000 12 Biology

1005 JIM 11 10000

What will be the output of the following statement?


SELECT * FROM Emp NATURAL JOIN Dept WHERE dname='Physics';

b) Write output of the queries (i) to (iv) based on the table Sportsclub
Table Name: Sportsclub
playerid pname sports country rating salary

10001 PELE SOCCER BRAZIL A 50000

10002 FEDERER TENNIS SWEDEN A 20000

10003 VIRAT CRICKET INDIA A 15000

10004 SANIA TENNIS INDIA B 5000

10005 NEERAJ ATHLETICS INDIA A 12000

10006 BOLT ATHLETICS JAMAICA A 8000

5|Page
10007 PAUL SNOOKER USA B 10000

(i) SELECT DISTINCT sports FROM Sportsclub;


(ii) SELECT sports, MAX(salary) FROM Sportsclub GROUP BY sports
HAVING sports<>'SNOOKER';
(iii) SELECT pname, sports, salary FROM Sportsclub WHERE
country='INDIA' ORDER BY salary DESC;
(iv) SELECT SUM(salary) FROM Sportsclub WHERE rating='B';
27 A pre-existing text file data.txt has some words written in it. Write a python 3
. function displaywords() that will print all the words that are having length
greater than 3.
Example:
For the fie content:
A man always wants to strive higher in his life
He wants to be perfect.

The output after executing displayword() will be:


Always wants strive higher life wants perfect

OR

A pre-existing text file info.txt has some text written in it. Write a python
function countvowel() that reads the contents of the file and counts the
occurrence of vowels(A,E,I,O,U) in the file.
28 Based on the given set of tables write answers to the following questions. 3
. Table: flights
flightid model company
10 747 Boeing
12 320 Airbus
15 767 Boeing
Table: Booking
ticketno passenger source destination quantity price Flightid
10001 ARUN BAN DEL 2 7000 10
10002 ORAM BAN KOL 3 7500 12
10003 SUMITA DEL MUM 1 6000 15
10004 ALI MUM KOL 2 5600 12
10005 GAGAN MUM DEL 4 5000 10
a) Write a query to display the passenger, source, model and price for all
bookings whose destination is KOL.
b) Identify the column acting as foreign key and the table name where it
is present in the given example.

6|Page
29 Write a function modilst(L) that accepts a list of numbers as argument and 3
. increases the value of the elements by 10 if the elements are divisible by 5.
Also write a proper call statement for the function.
For example:
If list L contains [3,5,10,12,15]
Then the modilist() should make the list L as [3,15,20,12,25]
30 A dictionary contains the names of some cities and their population in crore. 3
. Write a python function push(stack, data), that accepts an empty list, which
is the stack and data, which is the dictionary and pushes the names of those
countries onto the stack whose population is greater than 25 crores.
For example :
The data is having the contents {'India':140, 'USA':50, 'Russia':25, 'Japan':10}
then the execution of the function push() should push India and USA on the
stack.

OR

A list of numbers is used to populate the contents of a stack using a function


push(stack, data) where stack is an empty list and data is the list of numbers.
The function should push all the numbers that are even to the stack. Also
write the function pop() that removes the top element of the stack on its
each call.

SECTION D
31 Magnolia Infotech wants to set up their computer network in the Bangalore 5
. based campus having four buildings. Each block has a number of computers
that are required to be connected for ease of communication, resource
sharing and data security. You are required to suggest the best answers to
the questions i) to v) keeping in mind the building layout on the campus.

HR
Development

Admin
Logistics

Number of Computers.
Block Number of computers
Development 100
HR 120
Admin 200
Logistics 110

7|Page
Distance Between the various blocks
Block Distance
Development to HR 50m
Development to Admin 75m
Development to Logistics 120m
HR to Admin 110m
HR to Logistics 50m
Admin to Logistics 140m

i) Suggest the most appropriate block to host the Server. Also justify
your choice.
ii) Suggest the device that should should be placed in the Server
building so that they can connect to Internet Service Provider to
avail Internet Services.
iii) Suggest the wired medium and draw the cable block to block layout
to economically connect the various blocks.
iv) Suggest the placement of Switches and Repeaters in the network
with justification.
v) Suggest the high-speed wired communication medium between
Bangalore Campus and Mysore campus to establish a data network.
32 a) Write the output of the following code: 2+3
.
def change(m, n=10):
global x
x+=m
n+=x
m=n+x
print(m,n,x)
x=20
change(10)
change(20)

OR (only in a part)

What will be the output of the following python program?


str = ""
name = "9@Days"
for x in name:
if x in "aeiou":
str+=x.upper()
elif not x.isalnum():
8|Page
str+="**"
elif x.isdigit():
pass
else:
str+=x.lower()
print(str)
b) Sumitra wants to write a program to connect to MySQL database using
python and increase the age of all the students who are studying in class 11
by 2 years.
Since she had little understanding of the coding, she left a few blank spaces
in her code. Now help her to complete the code by suggesting correct coding
for statements 1, 2 and 3.
import ________________ as myc # Statement 1
con = myc.connect(host="locahost", user="root", passwd="",
database="mydb")
mycursor = __________________ #Statement 2
sql = "UPDATE student SET age=age+2 WHERE class='XI'"
mycursor.execute(sql)
sql = "SELECT * FROM student"
mycursor=con.execute(sql)
result = _____________________ #Statement 3
for row in result:
print(row)

Statement 1 : The required module to be imported


Statement 2: To initialize the cursor object.
Statement 3: To read all the rows from the cursor object

33 A binary file data.dat needs to be created with following data written it in the 2+3
. form of Dictionaries.
Rollno Name Age
1001 TOM 17
1002 BOB 16
1003 KAY 16
Write the following functions in python accommodate the data and
manipulate it.
a) A function insert() that creates the data.dat file in your system and
writes the three dictionaries.
b) A function() read() that reads the data from the binary file and displays
the dictionaries whose age is 16.

9|Page
34 Tarun created the following table in MySQL to maintain stock for the items 1+1+
. he has. 2

Table : Inventory
Productid pname company stock price rating

10001 Biscuit Parley 1000 15 C

10002 Toffee Parley 500 5 B

10003 Eclairs Cadbury 800 10 A

10004 Cold Drink Coca Cola 500 25 NULL

1005 Biscuit Britania 500 30 NULL

1006 Chocolate Cadbury 700 50 C


Based on the above table answer the following questions.

a) Identify the primary key in the table with valid justification.


b) What is the degree and cardinality of the given table.
c) Write a query to increase the stock for all products whose company is
Parley.
OR (only for part c)
Write a query to delete all the rows from the table which are not
having any rating.
35 Sudheer has written a program to read and write using a csv file. He has
. written the following code but failed to write completely, leaving some
blanks. Help him to complete the program by writing the missing lines by
following the questions a) to d)

_________________ #Statement 1
headings = ['Country','Capital','Population']
data = [['India', 'Delhi',130],['USA','Washington DC',50],[Japan,Tokyo,2]]
f = open('country.csv','w', newline="")
csvwriter = csv.writer(f)
csvwriter.writerow(headings)
________________ #Statement 2
f.close()
f = open('country.csv','r')
csvreader = csv.reader(f)
head = _________________ #Statement 3
print(head)
for x in __________: #Statement 4
if int(x[2])>50:
print(x)
10 | P a g e
a) Statement 1 – Write the python statement that will allow Sudheer
work with csv files.
b) Statement 2 – Write a python statement that will write the list
containing the data available as a nested list in the csv file
c) Statement 3 – Write a python statement to read the header row in to
the head object.
d) Statement 4 – Write the object that contains the data that has been
read from the file.

****End****

11 | P a g e
Sample Paper 12
Computer Science (083)
CLASS – XII COMPUTER SCIENCE (083)
TIME ALLOWED: 03 HOURS CLASS XII 2023-24 M.M.: 70
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1. Fill in the Blank 1
The explicit conversion of an operand to a specific type is called _____
(a)Type casting (b) coercion (c) translation (d) None of these
2. Which of the following is not a core data type in Python? 1
(a)Lists (b) Dictionaries (c)Tuple (d) Class
3. What will the following code do? 1
dict={"Exam":"AISSCE", "Year":2022}
dict.update({"Year”:2023} )

a. It will create new dictionary dict={” Year”:2023}and old dictionary


will be deleted
b. It will throw an error and dictionary cannot updated
c. It will make the content of dictionary as dict={"Exam":"AISSCE",
"Year":2023}
d. It will throw an error and dictionary and do nothing
4. What will be the value of the expression :14+13%15 1
5 Select the correct output of the code: 1
a= "Year 2022 at All the best" a = a.split('2')
a = a[0] + ". " + a[1] + ". " + a[3] print (b)
(a) Year . 0. at All the best (b) Year 0. at All the best
(c) Year . 022. at All the best (d) Year . 0. at all the best

6. Which of the following mode will refer to binary data? 1


(a)r (b) w (c) + (d) b
7. Fill in the blank: 1
______ command is used to remove a column from a table in SQL.
(a) update (b)remove (c) alter (d)drop
8. Which of the following commands will delete the rows of table? 1
(a) DELETE command (b) DROP Command
(c) REMOVE Command (d) ALTER Command
9. Which of the following statement(s) would give an error after executing the following code? 1
S="Welcome to class XII" # Statement 1print(S) #
Statement 2 S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5

(a) Statement 3 (b) Statement 4


(b) Statement 5 (d) Statement 4 and 5
10. Logical Operators used in SQL are? 1
(a) AND,OR,NOT (b) &&,||,!
(c) $,|,! (d) None of these

1
11 The correct syntax of seek() is:
(a) file_object.seek(offset [, reference_point]) (b) seek(offset [,
reference_point])
(c) seek(offset, file_object) (d)
seek.file_object(offset)
12. Fill in the blank: 1
All tuples in the relation are assigned NULL as the value for the new Attribute,with the ________
Command
(a) MODIFY (b) TAILOR (c)ELIMINATE (d) ALTER
13. What is the size of IPv4 address? 1
(a)32 bits (b) 64 bits (c) 64 bytes (d) 32 bytes
14. What will be the output of the following expression? 1
24//6%3 , 24//4//2 , 48//3//4
a)(1,3,4) b)(0,3,4) c)(1,12,Error) d)(1,3,#error)
15. Which of the following ignores the NULL values inSQL? 1
a) Count(*) b) count() c)total(*) d)None of these
16. Which of the following is not a legal method for fetching records from a database from within a 1
Python program?
(a) fetchone() b)fetchtwo() (c) fetchall() (d) fetchmany()
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False (d) A is false but R is True
17. Assertion (A):- If the arguments in a function call statement match the number and order of 1
arguments as defined in the function definition, such arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains default argument(s)
followed by positional argument(s).
18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks like a 1
text file.
Reason (R): The information is organized with one record on each line and each field is separated
by comma.
SECTION B
19. Preety has written a code to add two numbers .Her code is having errors. Rewrite the correct 2
code and underline the corrections made.
def sum(arg1,arg2):
total=arg1+arg2;
print(”Total:”,total)
return total;
sum(10,20)
print(”Total:”,total)
20. Write two points of difference between Hub and Switch. 2
OR
Write two points of difference between Web PageL and Web site.
21. Write the output of following code and explain the difference between a*3 and (a,a,a) 2
a=(1,2,3)
print(a*3)
print(a,a,a)
22 Differentiate between DDL and DML with one Example each. 2
23 (a) Write the full forms of the following: 2
(i) SMTP (ii) PPP
(b) What is the use of TELNET?
24 What do you understand the default argument in function? Which function parameter must be given default 2
argument if it is used? Give example of function header to illustrate default argument
OR
Ravi a python programmer is working on a project, for some requirement, he has to define a function with
name CalculateInterest(), he defined it as:
def CalculateInterest (Principal, Rate=.06,Time): # code
But this code is not working, Can you help Ravi to identify the error in the above function and what is the
solution.

2
25 Write the output of the queries (a) to (d) based on the table 2

(a) SELECT min(Population) FROM country;


(b) SELECT max(SurfaceArea) FROM country Where Lifeexpectancy <50;
(c) SELECT avg(LifeExpectancy) FROM country Where CName Like "%G%";
(d) SELECT Count(Distinct Continent) FROM country;
OR
(a) Identify the candidate key(s) from the table Country.
(b) Consider the table CAPITAL given below:

Which field will be considered as the foreign key if the tables


COUNTRY and CAPITAL are related in a database?
SECTION-C
26 Write the outputs of the SQL queries (i) to (iii) based on the relations Teacher and Posting given below: 3
Table: Stationary
S_ID StationaryName Company Price
DP01 Dot Pen ABC 10
PL02 Pencil XYZ 6
ER05 Eraser XYZ 7
PL01 Pencil CAM 5
GP02 Gel Pen ABC 15
Table: Consumer
C_ID ConsumerName Address S_ID
1 Good Learner Delhi PL01
6 Write Well Mumbai GP02
12 Topper Delhi DP01
15 Write & Draw Delhi PL02
1. SELECT count(DISTINCT Address) FROM Consumer;
2. 2. SELECT Company, MAX(Price), MIN(Price), COUNT(*) from Stationary
GROUP BY Company;
SELECT Consumer.ConsumerName, Stationary.StationaryName, Stationary.Price FROM Stationary,
Consumer WHERE Consumer.S_ID = Stationary.S_ID;
27. Write a function COUNT_AND( ) in Python to read the text file “STORY.TXT” and count the 3
number of times “AND” occurs in the file. (include AND/and/And in the counting)
OR
Write a function DISPLAYWORDS( ) in python to display the count of words starting with “t” or “T”
in a text file ‘STORY.TXT’.
28 (Write a output for SQL queries (i) to (iii), which are based on the table: SCHOOL and ADMIN given 3
below:

3
SELECT SUM (PERIODS), SUBJECT FROM SCHOOL GROUP BY SUBJECT;
ii) SELECT TEACHERNAME, GENDER FROM SCHOOL, ADMIN WHERE
DESIGNATION = ‘COORDINATOR’ AND SCHOOL.CODE=ADMIN.CODE;
iii) SELECT COUNT (DISTINCT SUBJECT) FROM SCHOOL;
29. Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the 3
function. The function returns another list named ‘indexList’ that stores the indices of all Non-
Zero Elements of L.
For example:
If L contains [12,4,0,11,0,56]
The indexList will have - [0,1,3,5]
30. Write a program to perform push operations on a Stack containing Student details as given in the 3
following definition of student node:
RNo integer
Name String
Age integer
def isEmpty(stk):
if stk == [ ]:
return True
else:
return False
def stk_push(stk, item):
# Write the code to push student details using stack.
OR
Write a program to perform pop operations on a Stack containing Student details as given in the
following definition of student node:
RNo integer
Name String
Age integer
def isEmpty(stk):
if stk == [ ]:
return True
else:
return False
def stk_pop(stk):
# Write the code to pop a student using stack

4
SECTION D
31. MakeInIndia Corporation, an Uttarakhand based IT training company, is planning to set up training
centres in various cities in next 2 years. Their first campus is coming up in Kashipur district. At
Kashipur campus, they are planning to have 3 different blocks for App development, Web
designing and Movie editing. Each block has number of computers, which are required to be
connected in a network for communication, data and resource sharing. As a network consultant
of this company, you have to suggest the best network related solutions for them for
issues/problems raised in question nos. (i) to (v), keeping in mind the distances between various
Distance between various blocks/locations:
blocks/locations and other given parameters.
APP
KASHIPUR
DEVELOPM CAMPUS MOVIE
ENT EDITING
MUSSOORIE
CAMPUS
WEB
DESIGNING

Block Distance
App development to Web designing 28 m
App development to Movie editing 55 m
Web designing to Movie editing 32 m
Kashipur Campus to Mussoorie Campus 232 km
Number of computers
Block Number of Computers
App development 75
Web designing 50
Movie editing 80
(i) Suggest the most appropriate block/location to house the SERVER in the Kashipur campus
(out of the 3 blocks) to get the best and effective connectivity. Justify your answer. 1
1
(ii) Suggest a device/software to be installed in the Kashipur Campus to take care of data
1
security.
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to economically
connect various blocks within the Kashipur Campus.
1
(iv) Suggest the placement of the following devices with appropriate reasons:
aSwitch / Hub
b Repeater 1
(v) Suggest a protocol that shall be needed to provide Video Conferencing solution between
Kashipur Campus and Mussoorie Campus.

5
32. (a) What will be the output of following program: 2+3
s="welcome2kv"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'#'
print(m)

(b)The code given below reads the following record from the table named studentand
displays only those records who have marks greater than 75:
RollNo – integer
Name – string
Clas – integer
Marks – integer

Note the following to establish connectivity between Python and MYSQL:


• Username is root
• Password is tiger
• The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those students whose marks are
greater than 75.
Statement 3- to read the complete result of the query (records whose
marks are greater than 75) into the object named data, from the table student in the
database.
import mysql.connector as mysql def sql_data():
con1=mysql.connect(host="localhost",user="root", password="tiger",
database="school")
mycursor=_______________ #Statement 1 print("Students
with marks greater than 75 are :
")
_________________________ #Statement 2
data=__________________ #Statement 3 for i in data:
print(i)
print()
33. What is the advantage of using a csv file for permanent storage? Write a Program in Python that 5
defines and calls the following user defined 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 mobile to store employee id,
employee name and employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSV file named ‘record.csv’.
OR

Give any one point of difference between a binary file and a csv file. Write a Program in Python
that defines and calls the following user defined functions:

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


file ‘furdata.csv’. Each record consists of a list with field elements as fid, fname and fprice
to store furniture id, furniture name and furniture price respectively.
(ii) search()- To display the records of the furniture whose price is more than 10000.
SECTION E
6
34 Write SQL commands for the following queries (i) to (v) based on the relation 4

Trainer and Course given below:


(i) Display the Trainer Name, City & Salary in descending order of
their Hiredate.
(ii) To display the TNAME and CITY of Trainer who joined the Institute
in the month of December 2001.
(iii) To display TNAME, HIREDATE, CNAME, STARTDATE from
tables TRAINER and COURSE of all those courses whose FEES
is less than or equal to 10000.
(iv) To display number of Trainers from each city.
OR
(iv) To display the Trainer ID and Name of the trainer who are not
belongs to ‘Mumbai’ and ‘DELHI’

35. Anuj Kumar of class 12 is writing a program to create a CSV file “user.csv”
which will contain user name and password for some entries. He has written thefollowing code. As
a programmer, help him to successfully execute the giventask.
import _____________ # Line 1
def addCsvFile(UserName,PassWord): # to write / add data into the CSV file 4
f=open(' user.csv','________') # Line 2
newFileWriter = csv.writer(f)
newFileWriter.writerow([UserName,PassWord])
f.close()
#csv file reading code
def readCsvFile(): # to read data from CSV file
with open(' user.csv','r') as newFile:
newFileReader = csv._________(newFile) # Line 3
for row in newFileReader:
print (row[0],row[1])
newFile.______________ # Line 4
addCsvFile(“Arjun”,”123@456”)
addCsvFile(“Arunima”,”aru@nima”)
addCsvFile(“Frieda”,”myname@FRD”)

(a) Name the module he should import in Line 1.


(b) In which mode, Anuj 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.

*************************************** End of the Paper ***************************************

7
Sample Paper 13
Computer Science (083)
CLASS XII 2023-24
TIME: 03:00 HRS. MM: 70
General Instructions –
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q34 against part 3
only.
8. All programming questions are to be answered using Python Language only.

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

(a) ‘Ashok’, ‘Ramesh’


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

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


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

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

What will be the output of the following statement?

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


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

Write a method/function DISPLAYWORDS() in python to read lines from a text file


STORY.TXT, and display those words, which are less than 4 characters.
OR
Write a function RevText() to read a text file "Story.txt" and Print only word starting
27. with 'I' in reverse order. 3
Example:
If value in text file is:
INDIA IS MY COUNTRY
Output will be: AIDNI SI MY COUNTRY.
(a) Consider the following tables ACTIVITY and COACH.
2+
Write SQL commands for the statements (i) to (iv) and give the The outputs for the SQL
28. 1=
queries (v) to (viii) –
3
Table: ACTIVITY

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

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

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

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

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


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

A list contains following record of a customer:


[Customer_name, Phone_number, City]

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

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

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

The stack should contain:


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

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

OR

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

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

The dictionary should be as follows:

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

Then the output will be:


Umesh Vishal Ishika
SECTION – D

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

Distance between various blocks/locations:


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

Number of computers in each building are -


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

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


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

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

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

(b) The code given below inserts the following record in the table EMP:
EmpID – integer
Name – string
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
is root
kvs 2+
32.
KVS. 3
EmpID, Name, Salary) are to be accepted from the user.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table EMP.
Statement 3- to add the record permanently in the database

import mysql.connector as mysql


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

OR

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

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

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those students whose
marks are greater than 75.
Statement 3- to read the complete result of the query (records whose marks are
greater than 75) into the object named data, from the table student in the database.

import mysql.connector as mysql


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

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


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

Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user defined functions:

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

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

B001 Double Bed 03-Jan-2018 45000 10


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

T006 Console Table 17-Nov2019 15000 12 1+


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

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

import _______ #Statement 1


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

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


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

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

10 | P a g e
Sample Paper 14
Computer Science (083)
CLASS XII 2023-24

Max Marks-70 Time: 3 hrs

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 Identify the invalid Python statement from the following. 1
(a) _b=1 (b) __b1= 1 (c) b_=1 (d) 1 = _b

2 Identify the valid arithmetic operator in Python from the following. 1


(a) // (b) < (c) or (d) <>

3 If Statement in Python is __ 1
(a) looping statement (b) selection statement (c) iterative (d) sequential

4 Predict the correct output of the following Python statement – 1


print(4 + 3**3/2)

(a) 8 (b) 9 (c) 8.0 (d) 17.5

5 Choose the most correct statement among the following – 1

(a) a dictionary is a sequential set of elements


(b) a dictionary is a set of key-value pairs
(c) a dictionary is a sequential collection of elements key-value pairs
(d) a dictionary is a non-sequential collection of elements

6 Consider the string state = “Jharkhand”. Identify the appropriate statement that will display the last 1
five characters of the string state?

(a) state [-5:] (b) state [4:] (c) state [:4] (d) state [:-4]

7 What will be the output of the following lines of Python code? 1

if not False:
print(10)
else:
print(20)

Page 1 of 9
(a) 10 (b) 20 (c) True (d) False

8 Consider the Python statement: f.seek(10, 1) 1


Choose the correct statement from the following:

(a) file pointer will move 10 byte in forward direction from beginning of the file
(b) file pointer will move 10 byte in forward direction from end of the file
(c) file pointer will move 10 byte in forward direction from current location
(d) file pointer will move 10 byte in backward direction from current location

9 Which of the following function returns a list datatype? 1

a) d=f.read() b) d=f.read(10) c) d=f.readline() d) d=f.readlines()

10 Identify the device on the network which is responsible for forwarding data from one device to 1
another

(a) NIC (b) Router (c) RJ45 (d) Repeater

11 A table has initially 5 columns and 8 rows. Consider the following sequence of operations 1
performed on the table –
i. 8 rows are added
ii. 2 columns are added
iii. 3 rows are deleted
iv. 1 column is added
What will be the cardinality and degree of the table at the end of above operations?

(a) 13,8 (b) 8, 13 (c) 14,5 (d) 5,8

12 Which of the following constraint is used to prevent a duplicate value in a record? 1

(a) Empty (b) check (c) primary key (d) unique

13 The structure of the table/relation can be displayed using __________ command. 1

(a) view (b) describe (c) show (d) select

14 Which of the following clause is used to remove the duplicating rows from a select statement? 1

(a) or (b) distinct (c) any (d)unique

15 How do you change the file position to an offset value from the start? 1
(a) fp.seek(offset, 0) (b) fp.seek(offset, 1) (c) fp.seek(offset, 2) (d) None of them

16 Which of the following method is used to create a connection between the MySQL database and 1
Python?
(a) connector ( ) (b) connect ( ) (c) con ( ) (d) cont ( )

Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
Page 2 of 9
17 Assertion (A): The function definition calculate(a, b, c=1,d) will give error. 1
Reason (R): All the non-default arguments must precede the default arguments.

18 Assertion (A): CSV files are used to store the data generated by various social media platforms. 1
Reason (R): CSV file can be opened with MS Excel.

SECTION - B
19 Find error in the following code(if any) and correct code by rewriting code and underline the 2
correction;‐

x= int(“Enter value of x:”)


for in range [0,10]:
if x=y
print( x + y)
else:
print( x‐y)

20 (a) 2
Find output generated by the following code:

Str = "Computer"
Str = Str[-4:]
print(Str*2)

OR
Consider the following lines of codes in Python and write the appropriate output:

student = {'rollno':1001, 'name':'Akshay', 'age':17}


student['name']= “Abhay”
print(student)

21 What do you mean by Foreign key? How it is related with Referential Integrity? 2

22 Find output generated by the following code: 2


string="aabbcc"
count=3
while True:
if string[0]=='a':
string=string[2:]
elif string[-1]=='b':
string=string[:2]
else:
count+=1
break
print(string)
print(count)

23 Expand the following terms: 2


i. NIC
ii. TCP/IP
iii. POP
iv. SMTP

Page 3 of 9
24 Write one advantage and one disadvantage of each – STAR Topology and Tree Topology 2

OR

What do you mean by Guided Media? Name any three guided media?

25 Differentiate between DDL and DML? 2

OR

Write the main difference between INSERT and UPDATE Commands in SQL

SECTION - C
26 Write definition of a method/function AddOdd(VALUES) to display sum of odd values from the 3
list of VALUES

27 Define a function SHOWWORD () in python to read lines from a text file STORY.TXT, and 3
display those words, whose length is less than 5.

OR

Write a user defined function in python that displays the number of lines starting with 'H' in the file
para.txt

28 Write the outputs of the SQL queries (a) to (c) based on the relation Furniture 3

No Itemname Type Dateofstock Price Discount


1 White lotus Double Bed 23/02/2002 30000 25
2 Pink feather Baby Cot 20/01/2002 7000 20
3 Dolphin Baby Cot 19/02/2002 9500 20
4 Decent Office Table 01/01/2002 25000 30
5 Comfort Zone Double Bed 12/01/2002 25000 25
6 Donald Baby Cot 24/02/2002 6500 15
7 Royal finish Office Table 20/02/2002 18000 30
8 Royal tiger Sofa 22/02/2002 31000 30
9 Econo sitting Sofa 13/12/2001 9500 25
10 paradise Dining Table 19/02/2002 11500 25
11 Wood Comfort Double Bed 23/03/2003 25000 25
12 Old Fox Sofa 20/02/2003 17000 20
13 Micky Baby Cot 21/02/2003 7500 15

(a) SELECT Itemname FROM Furniture WHERE Type="Double Bed";


(b) SELECT MONTHNAME(Dateofstock) FROM Furniture WHERE Type="Sofa";
(c) SELECT Price*Discount FROM Furniture WHERE Dateofstock>31/12/02;
29 Consider the following table GAMES 3

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
Write the output for the following queries :
Page 4 of 9
(i) SELECT COUNT(DISTINCT Number) FROM GAMES;
(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(iii) SELECT SUM(PrizeMoney) FROM GAMES;

30 Write PushOn(Book) and Pop(Book) methods/functions in Python to add a new Book and delete a 3
Book from a list of Book titles, considering them to act as push and pop operations of the Stack data
structure.

OR

Mr.Ajay has created a list of elements. Help him to write a program in python with functions,
PushEl(element) and PopEl(element) to add a new element and delete an element from a List of
element Description, considering them to act as push and pop operations of the Stack data structure
. Push the element into the stack only when the element is divisible by 4.

For eg:if L=[2,5,6,8,24,32]


then stack content will be 32 24 8

SECTION - D
31 India Tech Solutions (ITS) is a professional consultancy company. The company is planning 5
to set up their new offices in India with its hub at Hyderabad. As a network adviser, you have
to understand their requirement and suggest them the best available solutions. Their queries
are mentioned as (i) to (v) below.

Physical locations of the blocks of TTC

HR BLOCK MEETING BLOCK

FINANCE BLOCK

Block to block distance (in m)


Block (From) Block (To) Distance
HR Block MEETING 110
HR Block Finance 40
MEETING Finance 80
Expected number of computers
Block Computers
HR 25
Finance 120
MEETING 90

(i)Which will be the most appropriate block, where TTC should plan to install their server?
(ii) Draw a block to block cable layout to connect all the buildings in the most appropriate
manner for efficient communication.
(iii)What will be the best possible connectivity out of the following, you will suggest to
connect the new set up of offices in Bengalore with its London based office.
• Satellite Link
• lInfrared
Page 5 of 9
• Ethernet
(iv)Which of the following device will be suggested by you to connect each computer in each
of the buildings?
• l Switch
• l Modem
• l Gateway
(v) Company is planning to connect its offices in Hyderabad which is less than 1 km. Which
type of network will be formed?

32 Find the output of the following: 2


(a)
fruit_list1 = ['Apple', 'Berry', 'Cherry', 'Papaya']
fruit_list2 = fruit_list1
fruit_list3 = fruit_list1[:]
fruit_list2[0] = 'Guava'
fruit_list3[1] = 'Kiwi'
sum = 0
for ls in (fruit_list1, fruit_list2, fruit_list3):
if ls[0] == 'Guava':
sum += 1
if ls[1] == 'Kiwi':
sum += 20
print (sum)

(b) Consider the table 3


TRAINER
TI TNAME CITY HIREDAT SALAR
D E Y
101 SUNAINA MUMBAI 1998‐10‐15 90000
102 ANAMIKA DELHI 1994‐12‐24 80000
103 DEEPTI CHANDIGA 2001‐12‐21 82000
RG
104 MEENAKSHI DELHI 2002‐12‐25 78000
105 RICHA MUMBAI 1996‐01‐12 95000
106 MANIPRAB CHENNAI 2001‐12‐12 69000
HA

The Following program code is used to increase the salary of Trainer SUNAINA by 2000.

Note the following to establish connectivity between Python and MYSQL:


Username is root
Password is system
The table exists in a MYSQL database named Admin.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Student.
Statement 3- to add the record permanently in the database

import mysql.connector as mydb


mycon = mydb.connect
(host = “localhost”,
user = “root”,
Page 6 of 9
passwd = “system”,
database = “Admin”)
cursor = _______________ #Statement 1
sql = “UPDATE TRAINER SET SALARY = SALARY + 2000
WHERE TNAME = ‘SUNAINA’”
cursor. _______________ #Statement 2
_______________ #Statement 3
mycon.close( )

OR
(a) Write the output of the following Python program code: 2
my_dict = {}
my_dict[(1,2,4)] = 8
my_dict[(4,2,1)] = 10
my_dict[(1,2)] = 12
sum = 0
for k in my_dict:
sum += my_dict[k]
print (sum)
print(my_dict)

(b) Consider the table 3


TABLE : GRADUATE
S.N NAME STIPEN SUBJECT AVERAG DI
O D E V
1 KARAN 400 PHYSICS 68 I
2 DIWAKA 450 COMP Sc 68 I
R
3 DIVYA 300 CHEMISTR 62 I
Y
4 REKHA 350 PHYSICS 63 I
5 ARJUN 500 MATHS 70 I
6 SABINA 400 CHEMISTR 55 II
Y
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

The Following program code is used to view the details of the graduate whose subject is
PHYSICS.

Note the following to establish connectivity between Python and MYSQL:


Username is root
Password is system
The table exists in a MYSQL database named Admin.

Write the following missing statements to complete the code:


Statement 1 – to import the proper module
Statement 2 – to create the cursor object.
Statement 3- to Close the connection
Page 7 of 9
import ______________ as mydb #Statement 1
mycon = mydb.connect
(host = “localhost”,
user = “root”,
passwd = “system”,
database = “Admin”)
cursor = _________________ #Statement 2
sql = “SELECT * FROM GRADUATE WHERE SUBJECT = ‘PHYSICS’”
cursor. execute(sql)
mycon.commit ( )
___________________ #Statement 3
33 Sumit is a programmer who is working on a project that requires student data of a school to be 5
stored in a CSV file. Student data consists of roll no, name, class and section. He has written a
program to obtain the student data from user and write it to a CSV file. After getting errors in
the program he left five statements blank in the program as shown below. Help him to find the
answer of the following questions to find the correct code for missing statements.
#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(“Class : ”)
section = input(“Enter Section : ”)
rec = [_____] #Statement 4
data.append(rec)
stuwriter. _____ (data) #Statement 5
fh.close()

(i) Identify the suitable code for blank space in line marked as Statement 1.
(ii) Identify the missing code for blank space in line marked as Statement 2.
(iii) Choose the function name (with argument) that should be used in the blank space of line
marked as Statement 3.
(iv) Identify the suitable code for blank space in line marked as Statement 4.
(v) Choose the function name that should be used in the blank space of line marked as
Statement 5 to create the desired CSV file?

OR

What are the advantages of binary file over text file? Write a Python program in Python to
search the details of the employees (name, designation and salary) whose salary is greater than
5000. The records are stored in the file emp.dat. consider each record in the file emp.dat as a
list containing name, designation and salary.

SECTION - E
34 Based on given table “DITERGENTS” answer following questions.
PID PName Price Category Manufacturer

Page 8 of 9
1 Nirma 40 Detergent Powder Nirma Group
2 Surf 80 Detergent Powder HL
3 Vim Bar 20 Disc washing Bar HL
4 Neem Face Wash 50 Face Wash Himalaya
a) Write SQL statement to display details of all the products not manufactured by HL. 1
b) Write SQL statement to display name of the detergent powder manufactured by HL. 1
c) Write SQL statement to display the name of the Product whose price is more than 0.5 2
hundred.

OR
c) Write SQL statement to display name of all such Product which start with letter ‘N’

35 Arun is a class XII student of computer science. The CCA in-charge of his school wants to 1+1+2
display the words form a text files which are less than 4 characters. With the help of his
computer teacher Arun has developed a method/function FindWords() for him in python
which read lines from a text file Thoughts. TXT, and display those words, which are lesser
than 4 characters. His teachers kept few blanks in between the code and asked him to fill the
blanks so that the code will run to find desired result. Do the needful with the following
python code.

def FindWords():
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
FindWords()

(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 characters

OR (Only for iii and iv above)


(v) Fill in the blank in Statement-5 to close the file.
(vi) Which method of text file will read only one line of the file?

Page 9 of 9
Sample Paper 15
Computer Science (083)
CLASS XII 2023-24

Maximum Marks: 70 Time Allowed: 3 hours


General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice isgiven in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION A
(Each question carries one mark)
1.What will be the output of the following python statement? 1
L=[3,6,9,12]
L=L+15
print(L)
(a)[3,6,9,12,15] (b) [18,21,24,27] (c) [5,3,6,9,12,15] (d) error

2.Identify the output of the following python statements 1


import random
for n in range(2,5,2):
print(random.randrange(1,n,end=’*’)
(a)1*3 (b) 2*3 (c) 1*3*4 (d)1*4

3.Which of the following is an invalid identifier? 1


(a)_123 (b) E_e12 (c) None (d) true

4.Consider the given expression: 1


7%5==2 and 4%2>0 or 15//2==7.5
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


s = "Question paper 2022-23"
s= s.split('2')
print(s)
(a) ['Question paper ', '0', '', '-', '3']
(b) ('Question paper ', '0', '', '-', '3')
(c) ['Question paper ', '0', '2', '', '-', '3']
(d) ('Question paper ', '0', '2', '', '-', '3')

6. Which of the following mode in file opening statement does not results in Nor generates an error if the file
does not exist? 1
(a) r (b) r+ (c) w+ (d) None of the above

7.Which of the following commands is not a DDL command? 1


(a) DROP (b) DELETE (c) CREATE (d) ALTER

8.Which of the following SQL statements is used to open a database named “SCHOOL”? 1
(a) CREATE DATABASE SCHOOL;
Page 1
(b) USE DATABASE SCHOOL;
(c) USE SCHOOL;
(d) SHOW DATABASE SCHOOL;

9.Identify the output of the following python code: 1


D={1:”one”,2:”two”, 3:”three”}
L=[]
for k,v in D.items():
if ‘o’ in v:
L.append(k)
print(L)
(a) [1,2] (b) [1,3] (c)[2,3] (d)[3,1]

10.A relation can have only one______key and one or more than one______keys. 1
(a) PRIMARY, CANDIDATE
(b) CANDIDATE, ALTERNATE
(c )CANDIDATE ,PRIMARY
(d) ALTERNATE, CANDIDATE

11.Which of the following is the correct usage for tell() of a file object? 1
(a) It places the file pointer at the desired offset in a file.
(b)It returns the byte position of the file pointer as an integer.
(c)It returns the entire content of the file.
(d) It tells the details about the file.

12.What are the minimum number of attributes required to create a table in MySQL? 1
(a) 1 (b) 2 (c) 0 (d)3

13._____is a standard mail protocol used to receive emails from a remote server to a local email client. 1
(a) SMTP (b) POP (c) HTTP (d) FTP

14.Which of the following is not a tuple in python? 1


(a) (10,20) (b) (10,) (c) (10) (d) All are tuples.

15.SUM(), ANG() and COUNT() are examples of ______functions. 1


(a) single row functions
(b) multiple row functions
(c) math function
(d) date function

16.What are the mandatory arguments which are required to connect a MySQL database to python? 1
(a) username, password, hostname, database name
(b) username, password, hostname
(c) username, password, hostname, port
(d) username, password, hostname, database name

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: The default value of an argument will be used inside a function if we do not pass a value to that
argument at the time of the function call. 1
Reason: the default arguments are optional during the function call. It overrides the default value if we provide
a value to the default arguments during function calls.
18. Assertion: Pickling is the process by which a Python object is converted to a byte stream. 1
Reason: load() method is used to write the objects in a binary file. dump() method is used to read data from a
binary file.

Page 2
SECTION B
Each Question Carry 2 marks
19. Rewrite the following code in python after removing all syntax error(s). Underline each correction done in
the code.
2
30=Value
for VAL in range(0,Value)
If val%4==0:
print (VAL*4)
Elseif val%5==0:
print (VAL+3)
else
print(VAL+10)

20.Write two points of difference between Bus Topology and Tree Topology. 2
OR
Write two points of difference between Packet Switching and Circuit Switching techniques?

21. (a) Given is a Python string declaration: 2


s=”Up Above The World So High”
Write the output of:
print(s[::-4])
(b)Write the output of the code given below:
D={‘month’:’DECEMBER’,’exam’:’PREBOARD1’}
D[‘month’]=’JANUARY’
D[‘EXAM’]=’PRE2’
print(D.items())

22. Differentiate between CHAR(N) and VARCHAR(N). 2

23. (a) Expand the following abbreviations: 2


i)POP ii)HTTPS
(b) What is a URL?

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


L=[4,6,7,1,6,9,4]
def fun(L):
for i in range(len(L)):
if(L[i]%3==0 and L[i]%2==0):
L[i]=L[i]+1
print(L)
return(L)
print(L)
k=fun()
print(k)
OR
Predict the output of the Python code given below:
T = (9,18,27,36,45,54)
L=list(T)
L1 = []
for i in L:
if i%6==0:
L1.append(i)
T1 = tuple(L1)
print(T1)

Page 3
25. Differentiate between WHERE and HAVING with appropriate examples. 2
OR
Differentiate between COUNT() AND COUNT(*) with appropriate examples.

SECTION C
Each Question Carry 3 Marks
26.(a)Write SQL query to add a column total price with datatype numeric and size 10, 2 in a table product.

1+2
(b) Consider the following tables SCHOOL and ADMIN. Give the output the following SQL queries:

i.SELECT Designation COUNT (*) FROM Admin GROUP BY Designation HAVING COUNT (*) <2;
ii.SELECT max (EXPERIENCE) FROM SCHOOL;
iii.SELECT TEACHER FROM SCHOOL WHERE EXPERIENCE >12 ORDER BY TEACHER;
iv.SELECT COUNT (*), GENDER FROM ADMIN GROUP BY GENDER;
27. Write a program to count the words “to” and “the” present in a text file “python.txt”. 3
OR
A text file “PYTHON.TXT” contains alphanumeric text. Write a program that reads this text file and writes to
another file “PYTHON1.TXT” entire file except the numbers or digits in the file.

28. (a)Sonal needs to display name of teachers, who have “0” as the third character in their name. She wrote
the following query. 1+2
SELECT NAME FROM TEACHER WHERE NAME = “$$0?”;
But the query is’nt producing the result. Identify the problem.
(b)Write output for (i) & (iv) based on table COMPANY and CUSTOMER.

Page 4
i. SELECT COUNT(*) , CITY FROM COMPANY GROUP BY CITY;
ii. SELECT MIN(PRICE), MAX(PRICE) FROM CUSTOMER WHERE QTY>10;
iii. SELECT AVG(QTY) FROM CUSTOMER WHERE NAME LIKE “%r%;
iv. SELECT PRODUCTNAME, CITY, PRICE FROM COMPANY, CUSTOMER
WHERE COMPANY.CID=CUSTOMER.CID AND PRODUCTNAME=”MOBILE”;

29. Write a function EVEN_LIST(L), where L is the list of elements passed as argument to the
function. 3
The function returns another list named‘evenList’ that stores the indices of all even numbers of L.

For example:
If L contains [12,4,3,11,13,56]
The evenList will have - [12,4,5]

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

PUSH()- Traverse the content of the List,L and push all the odd marks into the stack,S.
POP()- Pop and display the content of the stack.
Example: If the content of the list is as follows:
L=[87, 98, 65, 21, 54, 78, 59, 64, 32, 49]
Then the output of the code should be: 49 59 21 65 87
OR
Write a function in Python, Push(BItem) where , BItem is a dictionary containing the details of bakery items–
{Bname:price}.
The function should push the names of those items in the stack,S who have price less than 50.
For example:
If the dictionary contains the following data:
Bitem={"Bread":40,"Cake":250,"Muffins":80,"Biscuits":25}

The stack should contain


Bread
Biscuits

SECTION D
Each Question Carry 5 Marks
31. Perfect Edu Services Ltd. is an educational organization. It is planning to setup its India campus at Chennai
with its head office at Delhi. The Chennai campus has 4 main buildings – ADMIN, ENGINEERING,
BUSINESS and MEDIA. 5

You as a network expert have to suggest the best network related solutions for their problems raised in (i) to (v),
keeping in mind the distances between the buildings and other given parameters.

Page 5
(i) Suggest the most appropriate location of the server inside the CHENNAI campus (out of the 4
buildings), to get the best connectivity for maximum no. of computers. Justify your answer.
(ii) Suggest and draw the cable layout to efficiently connect various buildings within the CHENNAI
campus for connecting the computers.
(iii) Which hardware device will you suggest to be procured by the company to be installed to protect
and control the internet uses within the campus ?
(iv) Which of the following will you suggest to establish the online face-to-face communication
between the people in the Admin Office of CHENNAI campus and DELHI Head Office ?
(a) Cable TV
(b) Email
(c) Video Conferencing
(d) Text Chat
(v) Name protocols used to send and receive emails between CHENNAI and DELHI office?

32.(a) Suppose the contents of text file quotes.txt is: 2+3


“Believe you can and you will!”
What will be the output of the following python code?
F=open(“quotes.txt”)
F.seek(17)
S=F.read()
print(S.split(‘o’))
(b) Pikato wrote a program which he wants to use to connect with MySQL and show the name of the all the
record from the table “Student” from the database “School”. You are required to complete the statements so
that the code can be executed properly.

import_____.connector____pymysql # statement 1
dbcon=pymysql.__(host=”localhost”,user=”root”,__=”sia@1928”,__)# statement 2
if dbcon.isconnected()==False:
print(“Error in establishing connection:”)
cur=dbcon.______________() # statement 3
query=”select * from stmaster”
cur.execute(_________) # statement 4
resultset=cur.fetchmany(3)
for row in resultset:
print(row)
dbcon.______() # statement 5
OR
(a) Predict the output of the following python code snippet:
s="Hello2everyone"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)

Page 6
(b) Preety has written the code given below to read the following record from the table named employee and
displays only those records who have salary greater than 53500:
Empcode – integer
EmpName – string
EmpSalary – integer

Note the following to establish connectivity between Python and MYSQL:


• Username is root
• Password is root@123
• The table exists in a MYSQL database named management.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those employees whose salary are greater than
53500.
Statement 3- to read the complete result of the query (records whose salary are greater than 53500) into the
object named data, from the table employee in the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root", password="root@123",
database="management")
mycursor=_______________ #Statement 1
print("Employees with salary greater than 53500 are : ")
_________________________ #Statement2
data=__________________ #Statement 3
for i in data:
print(i)
print()

33. What is the advantage of using a csv file for permanent storage? 1+4
Write a Program in Python that defines and calls the following user defined
functions:
a) ADD() – To accept and add data of an employee to a CSV file ‘record.csv’. Each record consists of a list
with field elements as empid, name and mobile to store employee id, employee name and employee salary
respectively.
b) COUNTR() – To count the number of records present in the CSV file named ‘record.csv’.

OR

Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user defined functions:
a) add() – To accept and add data of an employee to a CSV file ‘furdata.csv’. Each record consists of a list
with field elements as fid, fname and fprice to store furniture id, furniture name and furniture price
respectively.
b) search()- To display the records of the furniture whose price is more than 10000.

SECTION E
Each question carries 4 marks
34. Write a python program to create a csv file dvd.csv and write 10 records in it Dvdid, dvd name, qty, price.
Display those dvd details whose dvd price is more than 25. 4

35.Consider the table in Q26(b), write SQL Queries for the following: 4
i. To display TEACHERNAME, PERIODS of all teachers whose periods are more than 25.
ii. To display all the information from the table SCHOOL in descending order of experience.
iii. To display DESIGNATION without duplicate entries from the table ADMIN.
iv. To display TEACHERNAME, CODE and corresponding DESIGNATION from tables SCHOOL
and ADMIN of Male teachers.

Page 7
Page 8
Sample Paper 16
Computer Science (083)
CLASS XII 2023-24

Max. Marks: 70 Time: 3 hrs


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 isgiven in Q35
against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1. Identify the incorrect variable name: (1)
a) int b) float c) while d) true
2. What will be the data type of of the expression 12/5==0? (1)
a) True b) False c) bool d) float
3. What will be output of the following code: (1)
d1={1:2,3:4,5:6}
d2=d1.get(3,5)
print(d2)
a) 3 b) 4 c) 5 d) Error

4. Consider the given expression: (1)


8 and 13 > 10
Which of the following is the correct value of the expression?
a) True b) False c) None d) NULL
5. Fill in the blank: (1)
command is used to remove a column from a table in SQL.
a) update b) remove c) alter d)drop
6. Which of the following mode in file opening statement generates an error ifthe file (1)
does not exist?
a) a+ b) r+ c) w+ d) None of these
7. Which of the following commands will delete a table from a MYSQL database? (1)
a) DELETE b) DROP c) REMOVE d) ALTER

8. Fill in the blank: (1)


An alternate key is a , which is not the primary key of the table.
a) Primary Key b) Foreign Key c) Candidate Key d) Alternate Key

1
9. Select the correct output of the code: (1)
a = "assistance"
a = a.partition('a')
b = a[0] + "-" + a[1] + "-" + a[2]
print (b)
a) -a-ssistance b) -a-ssist-nce
c) a-ssist-nce d) -a-ssist-ance

10. Which of the following statement(s) would give an error during execution? (1)
S=("CBSE") # Statement 1
S+="Delhi" # Statement 2
S[0]= '@' # Statement 3
S=S+"Thank you" # Statement 4
a) Statement 1 b) Statement 2 c) Statement 3 d) Statement 4

11. tell() is a method of: (1)


a) pickle module b) csv module c) file object d) seek()

12. Select the correct statement, with reference to RDBMS: (1)


a) NULL can be a value in a Primary Key column
b) '' (Empty string) can be a value in a Primary Key column
c) A table with a Primary Key column cannot have an alternate key.
d) A table with a Primary Key column must have an alternate key.

13. Which protocol is used for transferring files over a TCP/IP network? (1)
a) FTP b) SMTP c) PPP d) HTTP
14. What will the following expression be evaluated to in Python? (1)
27 % 7 // (3 / 2)
a) 2 b) 2.0 c) 4.0 d) 4
15. Which function cannot be used with string type data? (1)
a) min() b) max() c) count() d) sum()
16. In context of Python - Database connectivity, the function fetchmany()is a method of (1)
which object?
a) connection b) database c) cursor d) query
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
c) A is True but R is False
d) A is false but R is True

17. Assertion (A):- print(f1()) is a valid statement even if the function f1() (1)
has no return statement.
Reasoning (R):- A function always returns a value even if it has no return
statement.

18. Assertion (A): If L is a list, then L+=range(5)is an invalid statement.Reason (R): Only (1)
a list can be concatenated to a list.

SECTION B

2
19. Mohit has written a code to input a positive integer and display its factorial. His code is (2)
having errors. Rewrite the correct code and underline the corrections made. (factorial of
a number n is the product 1x2x3. . .n)
n=int(input("Enter a positive integer: ")
f=0
for i in range(n):
f*=i
print(f)

20. Write two points of difference between LAN and MAN. (2)

OR

Write two points of difference between HTML and XML.

21. (a) Write a Python statement to display alternate characters of a string, named (1)
my_exam. For example, if my_exam="Russia Ukraine"
The statement should display Rsi kan

(b) Write the output of the code given below: (1)


d1 = {"name": "Aman", "age": 26}
d2 = d1.pop('name')
print(d1, d2)

22. Can a table in an RDBMS have multiple candidate keys? Can it have multiplePrimary (2)
keys? Give an example to support your answer.

23. (a) Write the full forms of the following: (i) VoIP (ii) IMAP (1)
(b) Name the communication medium which is used for WiFi. (1)

24. Predict the output of the Python code given below: (2)
def Alpha(N1): while
N1:
a=N1.pop()
if a%5>2: print(a,end='@') else: break
NUM=[13,24,12,53,34]
Alpha(NUM); print(NUM)
OR
Predict the output of the Python code given below:
T1 = tuple("Amsterdam")
T2, new_list = T1[1:-1], [] for i in T2:
if i in 'aeiou':
j=T1.index(i)
new_list+=[j]
print(new_list)

25. If a column score in a table match has five entries, viz. 30,65,NULL,40,NULL,then (2)
what will be the output of the following query?
Select count(*), avg(score) from match;
OR
Write two differences between HAVING and WHERE clauses in SQL.

3
SECTION C
26. (a) Consider the following table: (1)
Table: Employee

What is the degree and cardinality of table Employee, if it contains only the given
data? Which field fields is/are the most suitable to be the Primary key if the data
shown above is only the partial data? (2)
(b) Write the output of the queries (i) to (iv) based on the table Employee:
(i) select name, project from employee order by project;
(ii) select name, salary from employee where doj like'2015%';
(iii)select name, salary from employee where salary between 100000 and 200000;
(iv) select min(doj), max(dob) from employee;
27. Write a method count_words_e() in Python to read the content of a textfile and count (3)
the number of words ending with 'e' in the file.
Example: If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The count_words_e() function should display the output as:
No. of such words: 4
OR
Write a function reverseFile()in Python, which should read the content of a text file
“TESTFILE.TXT” and display all its line in the reverse order.

Example: If the file content is as follows:

It rained yesterday.
It might rain today.
I wish it rains tomorrow too.
I love Rain.

The RainCount() function should display the output as:

.yadretsey deniar tI
.yadot niar thgim tI
.oot worromot sniar ti hsiw I
.niaR evol I

4
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relationsProjects (2)
and Employee given below:

(i) select project, count(*) from employee group by project;


(ii) select pid, pname, eid, name from projects p, employee e where
p.pid=e.project;
(iii) select min(startdate), max(startdate) from projects;
(iv) select avg(salary) from employee where doj between '2018-08-19'
and '2018-08-31';

(b) Write the command to make Projects column of employee table a foreign key (1)
which refers to PID column of Projects table.

29. Write a function AdjustList(L), where L is a list of integers. The function should reverse (3)
the contents of the list without slicing the list and without using any second list.
Example: If the list initially contains 2, 15, 3, 14, 7, 9, 19, 6, 1, 10,
then after reversal the list should contain 10, 1, 6, 19, 9, 7, 14, 3, 15, 2

5
30. A nested list contains the data of visitors in a museum. Each of the inner lists contains (3)
the following data of a visitor:
[V_no (int), Date (string), Name (string), Gender (String M/F), Age (int)]
Write the following user defined functions to perform given operations on the stack
named "status":
(i) Push_element(Visitors) - To Push an object containing Gender of visitor who
are in the age range of 15 to 20.
(ii) Pop_element() - To Pop the objects from the stack and count the display the
number of Male and Female entries in the stack. Also, display “Done” when
there are no elements in the stack.
For example: If the list Visitors contains:
[['305', "10/11/2022", “Geeta”,"F”, 35],
['306', "10/11/2022", “Arham”,"M”, 15],
['307', "11/11/2022", “David”,"M”, 18],
['308', "11/11/2022", “Madhuri”,"F”, 17],
['309', "11/11/2022", “Sikandar”,"M”, 13]]
The stack should contain
F
M

M
The output should be:
Done
Female: 1
Male: 2
OR
Write the following functions in Python:
(i) Push(st, expression), where expression is a string containing a valid
arithmetic expression with +, -, *, and / operators, and st is a list representing
a stack. The function should push all the operators appearing in this
expression into the stack st.
(ii) Pop(st) to pop all the elements from the stack st and display them.It should
also display the message 'Stack Empty' when the stack becomes empty.
For example: If the expression is:
42*5.8*16/24-8+2
Then st should contain
+
-
/
*
*
The output should be:
+ - / * * Stack Empty

6
31. FutureTech Corporation, a Bihar based IT training and development company, is
planning to set up training centers in various cities in the coming year. Their first center
is coming up in Surajpur district. At Surajpur center, they are planning to have 3
different blocks - one for Admin, one for Training and one for Development. Each
block has number of computers, which are required to be connected in a network for
communication, data and resource sharing. As a network consultant of this company,
you have to suggest the best network related solutions for them for issues/problems
raised in question nos. (i) to (v), keeping in mind the distances between various
blocks/locations and other given parameters.

(i) Suggest the most appropriate block/location to house the SERVER in the Surajpur (1)
center (out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
(ii) Suggest why should a firewall be installed at the Surajpur Center? (1)
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to (1)
most efficiently connect various blocks within the Surajpur Center.
(iv) Suggest the placement of the following devices with appropriate reasons: (1)
a) Switch/Hub b) Router
(v) Suggest the best possible way to provide wireless connectivity between Surajpur
Center and Raipur Center. (1)

32. (a) Write the output of the code given below: (2)
p,q=8, [8]
def sum(r,s=5):
p=r+s
q=[r,s]
print(p, q, sep='@')
sum(3,4)
print(p, q, sep='@')

7
(b) The code given below accepts the increments the value of Clas by 1 foreach
student. The structure of a record of table Student is: (3)
RollNo – integer; Name – string; Clas – integer; Marks – integer
Note the following to establish connectivity between Python and MYSQL:
 Username is root, Password is abc
 The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:

import mysql.connector as mysql def sql_data():


con1=mysql.connect(host="localhost",user="root", password="abc")
#Statement 1
crsr.execute("use school")
#Statement 2
crsr.execute(querry)
# Statement 3
print("Data updated successfully")

Statement 1 – to create the cursor object.


Statement 2 – to create the query to update the table.
Statement 3- to make the updation in the database permanent
OR
(a) Predict the output of the code given below:
s="Rs.12"
n, m = len(s), ""
for i in range(0, n):
if s[i].islower():
m= m +s[i]
elif s[i].isupper():
m = m +s[i+1]
elif s[i].isdigit():
m = m*int(s[i])
else: m = '@'+m
print(m)

(b) The code given below reads records from the table named Vehicle and displays only
those records which have model later than 2010. The structure of a record of table
Vehicle is:
V_ID – integer; Name – string; Model – integer; Price – integer

Note the following to establish connectivity between Python and MYSQL:


 Username is root
 Password is abc
 The table exists in a MYSQL database named Transport.
 The details (RollNo, Name, Clas and Marks) 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 query that extracts records of those vehicles
whose model is greater than 2010.
Statement 3 - to read the complete result of the query into the object tnamed
data.

8
import mysql.connector as mysql
def display():
con1=mysql.connect(host="localhost",user="root", password="abc",
database="Transport")
#Statement 1
print("Students with marks greater than 75 are : ")
q="Select * from vehicle where model>2010"
#Statement 2
data= #Statement 3
for rec in data:
print(rec)
33. (a) What one advantage and one disadvantage of using a binary file for permanent (5)
storage?
(b) Write a Program in Python that defines and calls the following user defined
functions:
(i) ADD() – To accept and add data of an item to a CSV file ‘events.csv’. Each
record consists of Event_id, Description, Venue, Guests, and Cost.
(ii) COUNTR() – To read the data from the file events.csv, calculate and display the
average number of guests and average cost.
OR
(a) Give any one point of difference between a binary file and a text file.
(b) Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of an item to a binary file ‘events.dat’. Each
record of the file is a list [Event_id, Description, Venue, Guests, Cost].
Event_Id, Description, and venue are of str type, Guests and Cost are of
int type.
(ii) COUNTR() – To read the data from the file events.dat, calculate and display the
average number of guests and average cost.

SECTION E
34. Ifrah is a class XII student. She has created her Computer Science project in Python and (4)
saved the file with the name 'CarAgency.py'. Her code contains many blank lines.
Now she has written another Python script to remove all the bank lines from
'CarAgency.py' and to precede each line with a line number. For example, if
CarAgency.py originally contains:
import random, pickle

cars=[]

def estimate():
cost=0

Then after the program execution, the file 'CarAgency.py' should contain:
1. import random, pickle
2. cars=[]
3. def estimate():
4. cost=0

9
As a Python expert, help her to complete the following code (by completing
statements 1, 2, 3, and 4) based on the requirement given above.
(i) Statement-1 to import required functions.
(ii) Statement-2 to open temp.py in suitable mode.
(iii) Statement-3 to write line into temp.py
(iv) To delete CarAgency.py
from os #Statement 1
f1=open("CarAgency.py")
f2=open( , ) #Statement 2
i=1
for line in f1:
line=line.rstrip()
if len(line)>0:
line=str(i)+'.\t'+line+'\n'
i+=1
#Statement 3
f1.close()
f2.close()

#Statement 4
rename("temp.py","CarAgency.py")
35. Raghav has been assigned the task to create a database, named Projects. Healso has to (4)
create following two tables in the database:

Based on the given scenario, answer the following questions:

(i) Which table should he create first – Projects or Employee? Justify your answer.
(ii) What will be the degree of the Cartesian product of these two tables?
(iii) Write the SQL statement to create the table Employee.
(iv) Write the SQL statement to add a column Gender of type char(1) to the table
Employee, assuming that table Employee has already been created.
----------XXXXXXXXXX----------
10
Sample Paper 17
Computer Science (083)
CLASS XII 2023-24

MaximumMarks:70 TimeAllowed:3hours
GeneralInstructions:
1. This question paper contains fivesections,Section AtoE.
2. Allquestions arecompulsory.
3. Section Ahas 18 questions carrying 01 mark each.
4. Section B has 07 VeryShort Answertype questions carrying 02 marks each.
5. Section Chas 05 Short Answer typequestions carrying 03 marks each.
6. Section Dhas 03 Long Answertype questionscarrying 05 marks each.
7. Section Ehas 02 questions carrying 04 markseach. Internal choice is given in Q34 for
part c only.
8. Allprogramming questions aretobe answered using Python Language only.
SECTIONA

1. Assign a tuplecontaining anInteger? 1

2. Which of the following is valid identifier? 1

a) Serial_no. b) total-Marks c) _Percentaged) Hundred$

3. Add a pair of parentheses toeach expressionso that itevaluates toTrue. 1

a) 2 + 3 == 4 +5 ==7 b) 0 ==1 == 2

4. What willbetheoutputof following expressions: 1

a) 2**3**2 b) (2**3)**2

5. Consider thefollowing programand predict the output: 1

num1 = input("Entera numberand I'll triple it: ") #num1=8

num1 = num1 *3

print(num1)

6. Which of the following is used toread n characters from afile object“ f1” . 1

a)f1.read(n) b)f1(2) c)f1(read,2) d) allof the above

7. Name DDL command from following. 1

a) drop b)select c) insert d)update

8. What is thedefaultdateformatof Mysql. 1

a)’ dd-mm-yy’ b)’ d-m-y ‘ c) ‘ yyyy-mm-dd’ d) None

9. Which of the following statement(s) would givean error afterexecuting thefollowing 1


code?
S="Lucknowis theCapital of UP"#Statement 1

print(S) #Statement2

S[4]= '$’ #Statement 3

S="Thank you" #Statement 4

S=S +"Thank you" #Statement 5

(a) Statement3 (b) Statement 4 (c) Statement 5 (d) Statement 4 and 5

10. _________ isan attribute,whosevalues areUnique and not null. 1

(a) Primary Key (b) Foreign Key (c) CandidateKey (d) AlternateKey

11. Which of the following statements correctly explain the function of seek() method? 1

a. tells the currentposition withinthefile.

b. determines if you canmovethefileposition or not.

c. indicates thatthenext read or writeoccurs from thatposition in a file.

d. movesthecurrentfileposition to agiven specified position.

12. What is break statement in the context of flowof control in the python programming. 1

13. SMTP stands for___________________________. 1

14. What willbetheoutputof this code 1

>>>L1=[8,11,20]

>>>L1*3

15. Write command toviewtable structure. 1

16. Name any twoRDBMSsoftware. 1

Q17 and 18 areASSERTIONAND REASONING based questions. Mark thecorrect


choiceas

(a) Both Aand R are trueand Ris the correctexplanation forA

(b) BothA and Raretrue and Ris not thecorrect explanation for A

(c) AisTruebutR is False

(d) AisFalsebutR is True

17. Assertion(A): Function is defined as a set of statements writtenunder a specific name 1


in the python code

Reason(R): The complete block (set of statements) is used at different instances in


theprogram as and when required, referring the function name. It is a common code to
executefor different values(arguments),provided to a function.

18. Assertion(A): DBMS is an application packagewhich arranges the data in orderly 1


mannerin a tabularform.

Reason(R): Itis an interfacebetweendatabaseand theuser. It allows theusers to


access and perform various operations on stored data using sometools.

SECTIONB

19. Rewritethefollowing codein python after removing all syntaxerror(s). Underlineeach 2


correction donein the code.

30=n

fori in range(0,n)

IF i%4==0:

print (i*4)

Else:

print (i+4)

20. Write twopointsof differencebetween hub and switch. 2

OR

Differentiate Bus and Startopology

21. (a) Given is aPython string declaration: 2

Str1="##NEET Examination 2023##"

Write the output of: print(Str1[::-1])

(b) Writetheoutputof the codegivenbelow:

D1 ={"sname":"Aman", "age": 26}

D1['age'] =27

D1['address'] = "Delhi"

print(D1.items())

22. DefineTupleand Attributewith appropriateexample. 2

23. Name twotop level domain names with theirarea of application. 2

24. What possible outputs(s) are expected to be displayed on screen at the time of 2
execution of the program from thefollowing code? Also specify the maximum values
thatcanbeassigned toeach of thevariables FROM and TO.
importrandom

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#70#

OR

What will be the output of thefollowing code?

def my_func(var1=100,var2=200):

var1+=10

var2 = var2 -10

return var1+var2

print(my_func(50),my_func())

25. Differentiatebetween char(n) and varchar(n) datatypes with respect todatabases. 2

OR

Consider thetable,student given below:

(a) Identify the degreeand cardinality of the table.

(b) Which field should bemade the primary key? Justify your answer.

SECTIONC

26. Meera has tocreatea databasenamed MYEARTHin MYSQL. Shenow needs tocreate 3
a tablenamed CITY in the database to store the records of variouscitiesacross the
globe. The tableCITY has the following structure:

Table: CITY

FIELDNAME DATATYPE REMARKS


CITYCODE CHAR(5) PrimaryKey

CITYNAME CHAR(30)

SIZE INTEGER(3)

AVGTEMP INTEGER

POLLUTIONRATE INTEGER

POPULATION INTEGER

Help hertocomplete the task bysuggesting appropriateSQLcommands.

27. Supposecontent of 'Myfile.txt' is 3

Humpty Dumpty sat on a wall

Humpty Dumpty had agreat fall

All the king's horses and all the king'smen

Couldn'tputHumpty togetheragain

Write apython function named RECORD to calculatetotalnumberof characters in


‘ Myfile.txt’

OR

Writea python function named CLRECORDtocalculate total numberof linesin


‘ Myfile.txt’

28. Write SQLCommand for the following. 3

a) Command used toviewthelistof tables in a database?

b) Command used toadd column in a database?

c) Command used to delete column from adatabase?

29. Write afunction in Python Convert() toreplaces elements having even values with its 3
half and elements having odd valueswith twice its valuein a list.

eg:if thelistcontains3,4,5,16,9 then

rearranged list as 6,2,10,8, 18

30. Write afunction in Python PUSH_IN(L), whereLis a list of numbers. Fromthislist,push 3


allnumbers which aremultipleof 3 intoa stack which is implemented by using another
list.

OR

Write afunction in Python POP(Arr),where Arris a stack implemented by a list of


numbers. Thefunction returns thevalue deleted fromthestack.

SECTIOND

31. Acompany ABCEnterprises has four blocks of buildings as shown: 5

B1 B2

B3 B4

Centretocenterdistancebetweenvariousblocks: Numberofcomputersineachblock: Co
B3 TO B1 50 M B1 150 mp
uter
B1 TO B2 60 M B2 15 sin

B2 TO B4 25 M B3 15 eac
h
B4 TO B3 170 M B4 25 blo
ck
B3 TO B2 125 M
are
B1 TO B4 90 M net
wor
ked but blocks are not networked. Thecompany has now decided toconnectthe
blocks also.

(i) Suggest the mostappropriatetopology for theconnectionsbetween the


blocks.

(ii) Thecompany wants internet accessibility in alltheblocks. The suitable

and cost-effectivetechnology for that would be?

(iii) Which devices will yousuggestforconnecting allthecomputers with in eachof


theirblocks.

(iv) Thecompany is planning to link itshead office situated in New Delhi with the
offices in hilly areas. Suggest a way to connect iteconomically.

(v) Suggest the mostappropriatelocation of theserver,toget the best


connectivity formaximumnumberof computers.
32. a) What willbetheoutputof following code: 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) Differentiatebetween Selection and Projection operations incontext of a Relational


Database. Also, illustratethedifferencewith onesupporting example of each.

OR

a)Find and write the output of thefollowing Python code:

def Call(P=40,Q=20):

P=P+Q

Q=P– Q

print(P,'@',Q)

return P

R=200

S=100

R=Call(R,S)

print(R,'@',S)

S=Call(S)

print(R,'@',S)

b) Differentiatedomain and attribute?Explain with appropriateexample?

33. What is thefull formof csv? Which applications are used toread/edit thesefiles? 5
Writea Program inPython thatdefines and calls the following user defined functions:

(i) ADDR() – To acceptand add data of a studenttoa CSV file‘ record.csv’ . Each
record consists of a list with field elementsas rollno, nameand mobiletostoreroll
number name and mobileno of studentrespectively.

(ii)COUNTR() – Tocount the number of records present intheCSVfile named


‘ record.csv’ .

OR

Give any onepoint of differencebetween a textfileand a csvfile.

Writea Program inPython thatdefines and calls the following user defined functions:

(i) add() – Toacceptand add data of an employee’ s furnituredetailtoa CSVfile


‘ abc.csv’ . Each record consists of alist with field elementsas fid,fnameand fprice
tostorefurnitureid, furniturename and furniturepricerespectively.

(ii) search()-Todisplay therecords of the furniturewhosepriceis morethan5000.

SectionE

34. Write SQLcommands for the following questions (i) to (iv) based on the relations 1+1
Teacher and Posting given below(assumenoconstraint isadded tothetable): +2

Table: Teacher

T_ID Name Age Department Date_of_join Salary Gender

1 Jugal 34 Computer Sc 10/01/2017 12000 M

2 Sharmila 31 History 24/03/2008 20000 F

3 Sandeep 32 Mathematics 12/12/2016 30000 M

4 Sangeeta 35 History 01/07/2015 40000 F

5 Rakesh 42 Mathematics 05/09/2007 25000 M

6 Shyam 50 History 27/06/2008 30000 M

7 ShivOm 44 Computer Sc 25/02/2017 21000 M

8 Shalakha 33 Mathematics 31/07/2018 20000 F

Table: Posting

P_ID Department Place

1 History Agra
2 Mathematics Raipur

3 ComputerScience Delhi

a)Toadd primary keyin Teacher(T_ID)

b)To add new attribute named P_IDtoTeacher table.

c)To add foreign key to newly created column P_ID in TeacherTable assuming that

whosevalues arereferred from P_ID column of posting table.

OR(option for partc) only)

c)To changedata typeof placecolumn of posting tablefromchar tovarchar.

35. Sumit is a Python programmer. He has written a code and created a binary file 1+1
record.dat with employeeid, ename and salary. The file contains 10 records. He now +2
has to update a record based on the employee id entered by the user and update the
salary. The updated record is then to be written in the file temp.dat. The records which
are not to be updated also have to be written to the file temp.dat. If the employee id is
not found, an appropriate message should to be displayed. As a Python expert, help
himtocompletethefollowing code based on therequirementgiven above:

import_______#Statement 1

def update_data():

rec={}

fin=open("record.dat","rb")

fout=open("_____________") #Statement2

found=False

eid=int(input("Enter employee id to updatetheir 14 salary ::"))

while True:

try:

rec=______________#Statement 3

if rec["Employee id"]==eid:

found=True

rec["Salary"]=int(input("Enternewsalary :: "))

pickle.____________ #Statement 4
else:

pickle.dump(rec,fout)

except:

break

if found==True:

print("Thesalary of employee id ",eid,"has beenupdated.")

else:

print("Noemployeewith such id is not found")

fin.close()

fout.close()

(i) Which module should beimported in theprogram? (Statement 1)

(ii) Write the correctstatement required to open a temporary file named temp.dat.
(Statement2)

(iii) Which statement should Aman fill in Statement 3 toread the data from the
binary file,record.datand in Statement 4 towritetheupdated datain thefile,
temp.dat?
Sample Paper 18
Computer Science (083)
CLASS XII 2023-24
Maximum Marks: 70 Time Allowed: 3 hours

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is
given in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

QNo SECTION-A Marks


1 Which command comes under TCL(Transaction Control Language)? 1
(a)alter (b)update (c) grant (d) create
2 Which of the following is an invalid datatype in Python?
(a) list (b) Dictionary (c)Tuple (d)Class 1
3 Given the following dictionaries
dict_fruit={"Kiwi":"Brown", "Cherry":"Red"}
dict_vegetable={"Tomato":"Red", "Brinjal":"Purple"}
Which statement will merge the contents of both dictionaries? 1

(a) dict_fruit.update(dict_vegetable) (b) dict_fruit + dict_vegetable


(c) dict_fruit.add(dict_vegetable) (d) dict_fruit.merge(dict_vegetable)
4 Consider the given expression:
not False and False or True
Which of the following will be correct output if the given expression is 1
evaluated?
True b.False c. NONE d. NULL
5 Select the correct output of the code:

(a) 0 1 2 ….. 15 (b)Infinite loop


(c) 0 3 6 9 12 15 (d) 0 3 6 9 12
6 Which of the following is not a valid mode to open a file?
1
(a) ab (b) r+ (c) w+ (d) rw
7 Fill in the blank:
command is used to delete the table from the database of SQL. 1
(a) update (b)remove (c) alter (d) drop
8 Which of the following commands will use to change the structure of table in
MYSQL database?
(a)DELETE TABLE (b)DROP TABLE 1
(c)REMOVE TABLE (d)ALTER TABLE
9 What possible output(s) are expected to be displayed on screen at the time of
execution of the program from the following code?
import random
points=[20,40,10,30,15]
points=[30,50,20,40,45]
begin=random.randint(1,3) 1
last=random.randint(2,4)
for c in range(begin,last+1):
print(points[c],"#")
(a) 20#50#30# (b) 20#40#45
(c) 50#20#40# (d) both (b) and (c)
10 Fill in the blank:
is an attribute whose value is derived from the primary key
of some other table.
1
(a) Primary Key (b) Foreign Key
(c) Candidate Key (d) Alternate Key

11 The tell() function returns:


(a) Number of bytes remaining to be read from the file
(b) Number of bytes already read from the file
(c) Number of the byte written to the file 1
(d) Total number of bytes in the file

12 Fill in the blank:


The SELECT statement when combined with_________function,
returns number of rows present in the table. 1
(a) DISTINCT (b) UNIQUE (c) COUNT (d) AVG

13 Which switching technique follows the store and forward mechanism?


(a) Circuit switching (b) message switching
1
(c) packet switching (d) All of these

14 What will the following expression be evaluated to in Python?


print(16-(3+2)*5+2**3*4) 1
(a) 54 (b) 46 (c) 23 (d) 32
15 Which function is used to display the unique values of a column of a table?
1
(a) sum() (b) unique() (c)distinct() (d)return()
16 To establish a connection between Python and SQL database, connect() is
used. Which of the following value can be given to the keyword argument –
host, while calling connect ()?
(a) localhost 1
(b) 127.0.0.1
(c) any one of (a) or (b)
(d) localmachine
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
1
(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 the function calls.
Reasoning (R):- when you use keyword arguments in a function call, the 1
caller identifies the arguments by parameter name.
18 Assertion (A): CSV stands for Comma Separated Values
Reason (R): CSV files are a common file format for transferring and storing 1
data.
SECTION-B
19 Observe the following Python code very carefully and rewrite it after 2
removing all syntactical errors with each correction underlined.
DEF execmain():
x = input("Enter a number:")
if (abs(x)== x)
print("You entered a positive number")
else:
x=*1
print("Number made positive:" x )
20 Write two differences between Coaxial and Fiber transmission media. 2
OR
Write components of data communication.

21 (a) Given is a Python string declaration: 1+1 =2


message="Bring it on!!!"
Write the output of: print(message[::-2])
(b) Write the output of the code given below:
book_dict = {"title": "You can win", “copies”:15}
book_dict['author'] = “Shiv Khera”
book_dict['genre'] = "Motivation"
print(book_dict.items())
22 How many candidate key and primary key a table can have? Can we declare 2
combination of fields as a primary key?
23 (a) Write the full forms of the following: 1+1=2
(i) FTP (ii) MAC
(b) What is the use of TELNET?
24 Predict the output of the Python code given below: 2
def Swap (a,b ) :
if a>b:
print(“changed ”,end=“”)
return b,a
else:
print(“unchanged ”,end=“”)
return a,b
data=[11,22,16,50,30]
for i in range (4,0,-1):
print(Swap(data[i],data[i-1]))
OR
Predict the output of the Python code given below:
P = (10, 20, 30, 40, 50 ,60,70,80,90)
Q =list(P)
R = []
for i in Q:
if i%3==0:
R.append(i)
R = tuple(R)
print(R)
25 Differentiate between DDL and DML commands with suitable example. 2
OR
What is the difference between WHERE and HAVING clause of SQL
statement?
SECTION – C
26 (a)Consider the following tables – Bank_Account and Branch:
Bank_Account: 1+2=3
ACode Name Type
A01 Amit Savings
A02 Parth Current
A03 Mira Current
Branch:
ACode City
A01 Delhi
A02 Jaipur
A01 Ajmer
What will be the output of the following statement?
SELECT * FROM Bank_Account NATURAL JOIN Branch;
(b) Give the output of the following sql statements as per table given above.
Table : SPORTS
StudentNo Class Name Game1 Grade1 Game2 Grade2
10 7 Sammer Cricket B Swimming A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Venna Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Athletics C
i. SELECT COUNT(*) FROM SPORTS.
ii. SELECT DISTINCT Class FROM SPORTS.
iii. SELECT MAX(Class) FROM SPORTS;
iv. SELECT COUNT(*) FROM SPORTS GROUP BY Game1;

27 Write a method COUNTLINES() in Python to read lines from text file 1+2
‘TESTFILE.TXT’ and display the lines which are starting with any article (a,
an, the) insensitive of the case.
Example:
If the file content is as follows:
Give what you want to get.
We all pray for everyone’s safety.
A marked difference will come in our country.
The Prime Minister is doing amazing things.
The COUNTLINES() function should display the output as:
The number of lines starting with any article are : 2

OR

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


of a text file “STORY.TXT” and then count and display the count of
occurrenceof alphabets G and P individually (including small cases g and
p too).
Example:
If the file content is as follows:

God helps those who help themselves.


Great way to be happy is to remain positive.
Punctuality is a great virtue.
The GPCount() function should display the output as:
The number of G or g: 3
The number of P or p : 6
28 (a) consider the following tables School and Admin and answer the following 2+1=3
questions:
TABLE: SCHOOL
CODE TEACHER SUBJECT DOJ PERIODS EXPERIENCE
1001 RAVI ENGLISH 12/03/2000 24 10
1009 PRIYA PHYSICS 03/09/1998 26 12
1203 LISA ENGLISH 09/04/2000 27 5
1045 YASH RAJ MATHS 24/08/2000 24 15
1123 GAGAN PHYSICS 16/07/1999 28 3
1167 HARISH CHEMISTRY 19/10/1999 27 5
1215 UMESH PHYSICS 11/05/1998 22 16
TABLE : ADMIN
CODE GENDER DESIGNATION
1001 MALE VICE PRINCIPAL
1009 FEMALE COORDINATOR
1203 FEMALE COORDINATOR
1045 MALE HOD
1123 MALE SENIOR TEACHER
1167 MALE SENIOR TEACHER
1215 MALE HOD

Give the output of the following SQL queries:


i. Select Designation, count(*) from Admin Group by Designation
having count(*)<2;
ii. Select max(experience) from school;
iii. Select teacher from school where experience >12 order by teacher;
iv. Select count(*), gender from admin group by gender;

(b) Write SQL command to delete a table from database.


29 Write a function Lshift(L), where L is the list of elements passes as an 3
argument to the function. The function shifts all the elements by one place
to the left and then print it.

For example:
If L contains [9,4,0,3,11,56]

The function will print - [4,0,3,11,56,9]


30 Write Add_New(Book) and Remove(Book) methods in Python to Add a new 1+2
Book and Remove a Book from a List of Books, considering them to act as
PUSH and POP operations of the data structure stack.
OR
Aalia has a list containing 10 integers. You need to help him create a program
with separate user defined functions to perform the following operations
based on this list.
➢ Traverse the content of the list and push the even numbers into a stack.
➢ Pop and display the content of the stack.
For example:
If the sample content of the list is as follows:
N=[12,13,34,56,21,79,98,22,35,38]
Sample output of the code should be:
38 22 98 56 34 12
SECTION – D
31 Trine Tech Corporation (TTC) is a professional consultancy company. The 5
company is planning to set up their new offices in India with its hub at
Hyderabad. As a network adviser, you have to understand their requirement
and suggest them the best available solutions. Their queries
are mentioned
as (i) to (v) below.

a) Which will be the most appropriate block, where TTC should plan to
install their server?
b) Draw a block to block cable layout to connect all the buildings in the most
appropriate manner for efficient communication.
c) What will be the best possible connectivity out of the following, you will
suggest to connect the new setup of offices in Bengalore with its London
based office.
● Satellite Link
● Infrared
● Ethernet
d) Which of the following device will be suggested by you to connect each
computer in each of the buildings?
● Switch
● Modem
● Gateway
e) Company is planning to connect its offices in Hyderabad which is less than
1 km. Which type of network will be formed?
32 (a) Write the output of the code given below: 2+3=5

(b)The code given below inserts the following record in the table
mobile:
import mysql.connector
mycon = mysql.connector.connect (host = “localhost”, user = “Admin”,
passwd = “Admin@123”, database = “connect”)
cursor = mycon. () # Statement 1
sql = “INSERT INTO Mobile (Name, Model, Price, Qty) VALUES (%s, %s, %s,
%s)” val = (“Samsung”, “Galaxy Pro”, 28000, 3)
cursor… (sql,val) #Statement 2
mycon. #Statement 3
Write the missing statement: Statement1 , Statement2 and Statement3
OR
(a) Predict the output of the code given below:

(b) The code given below reads the following record from the tablenamed
student and displays only those records who have marks greater than
80:
RollNo – integer
Name – string
Clas – integer
Marks – integer
Note the following to establish connectivity between Python andMYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named kvs.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object

Statement 2 – to execute the query that extracts records of thosestudents


whose marks are greater than 80.

Statement 3- to read the complete result of the query (records whose


marks are greater than 80) into the object named data, from thetable
studentin the database.

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root",passwo rd="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)
33 (a) What does CSV stand for? 1+2+2=
(b) Write a Program in Python that defines and calls the following user 5
defined functions:
(i) InsertRow() – To accept and insert data of an student to a CSV file
‘class.csv’. Each record consists of a list with field elements as rollno,
name and marks to store roll number, student’s name and marks
respectively.
(ii) COUNTD() – To count and return the number of students who
scored marks greater than 75 in the CSV file named ‘class.csv’.
OR

Dhirendra is a programmer, who has recently been given a task to write a


python code to perform the following CSV file operations with the help of
two user defined functions/modules:

a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode


containing information of books – Title, Author and Price.
b. CSVRead() : to display the records from the CSV file called BOOKS.CSV
where the field title starts with 'R'.
He has succeeded in writing partial code and has missed out certain
statements, so he has left certain queries in comment lines.

import csv
def CSVOpen():
with open('books.csv','_____',newline='') as csvf: #Statement-1
cw=_____________#Statement-2
__________________#Statement-3
cw.writerow(['Rapunzel','Jack',300])
cw.writerow(['Barbie','Doll',900])
cw.writerow(['Johnny','Jane',280])
def CSVRead():
try:
with open('books.csv','r') as csvf:
cr=_________________#Statement-4
for r in cr:
if : #Statement-5 print(r)
except:
print('File Not Found')
CSVOpen()
CSVRead()

You as an expert of Python have to provide the missing statements and


other related queries based on the following code of Raman.

(i) Choose the appropriate mode in which the file is to be opened in


append mode (Statement 1)
(ii) Which statement will be used to create a csv writer object in
Statement 2.
(iii) Choose the correct option for Statement 3 to write the names of the
column headings in the CSV file, BOOKS.CSV.
(iv)
(iv) Which statement will be used to read a csv file in Statement 4.

(v) Fill in the appropriate statement to check the field Title starting with
‘R’ for Statement 5 in the above program.
SECTION -E
34 Mayank creates a table RESULT with a set of records to maintain the marks 4
secured by students in sub1, sub2, sub3 and their GRADE. After creation of
the table, he has entered data of 7 students in the table.
Table : RESULT
ROLL_NO SNAME sub1 sub2 sub3 GRADE
101 KIRAN 366 410 402 I
102 NAYAN 300 350 325 I
103 ISHIKA 400 410 415 I
104 RENU 350 357 415 I
105 ARPITA 100 75 178 IV
106 SABRINA 100 205 217 II
107 NEELIMA 470 450 471 I
103 ISHIKA 400 410 415 I
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as
Primary key.
(ii) If two columns are added and 2 rows are deleted from the table result,
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- 108, Name- Aaditi, sub1- 470, sub2-444, sub3- 475,
Grade– I.
b. Increase the sub2 marks of the students by 3% whose name
begins with ‘N’.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of students securing Grade-IV.
b. Add a column REMARKS in the table with datatype as varcharwith 50
characters.
4
Reshabh is a programmer, who has recently been given a task to write a
35
python code 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.
He has succeeded in writing partial code and has missed out certain
statements, so he has left certain queries in comment lines. You as an
expert of Python have to provide the missing statements and other related
queries based on the following code of Reshabh.

import pickle
def AddStudents():
_____________________# statement 1 to open the binary file to write data
while True:
Rno = int(input("Rno :"))
Name = input("Name : ")
Percent = float(input("Percent :"))
L = [Rno, Name, Percent]
__________________#statement 2 to write the list L into the file
Choice = input("enter more (y/n): ")
if Choice in "nN":
break
F.close()
def GetStudents():
Total=0
Countrec=0
Countabove75=0
with open("STUDENT.DAT","rb") as F:
while True:
try:
___________________ #statement 3 to read from the file
Countrec+=1
Total+=R[2]
if R[2] > 75:
print(R[1], " has percent =",R[2])
Countabove75+=1
except:
break
if Countabove75==0:
print("No student has percentage more than 75")
print("average percent of class = ",_____________) #statement 4
AddStudents()
GetStudents()

(i) Which of the following commands is used to open the file “STUDENT.DAT”
for writing only in binary format? (marked as #1 in the Python code)
(ii) Which of the following commands is used to write the list L into the
binary file, STUDENT.DAT? (marked as #2 in the Python code)

(iii) Which of the following commands is used to read each record from the
binary file STUDENT.DAT? (marked as #3 in the Python code)

(iv) What expression will be placed in statement 4 to print the average


percent of the class.

************************
Sample Paper 19
Computer Science (083)
CLASS XII 2023-24
Max Marks : 70 Time : 3 Hrs

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given
in Q34 against part iii only.
8. All programming questions are to be answered using Python Language only.
SECTION A
1 Find the invalid identifier from the following 1
a) Marks@12 b) string_12 c)_bonus d)First_Name
2 Identify the valid declaration of Rec: 1
Rec=(1,‟Ashoka",50000)
a) List b) Tuple c)String d) Dictionary
3 Suppose a tuple Tup is declared as Tup = (12, 15, 63, 80) which of 1
the following is incorrect?
a) print(Tup[1]) b) Tup[2] = 90
c) print(min(Tup)) d) print(len(Tup))
4 The correct output of the given expression is: 1
True and not False or False
(a) False (b) True (c) None (d) Null
5 t1=(2,3,4,5,6) 1
print(t1.index(4))
output is
(a) 4 (b) 5 (c) 6 (d) 2
6 Which of the following modes is used to open a binary file for writing 1
(a) b (b) rb+ (c) wb (d) rb
7 Fill in the blank: 1
The ________ command is used in a WHERE clause to search for a
specified pattern in a column.
(a) match (b) similar (c) like (d) pattern
8 Which of the following commands is used to modify a table in SQL? 1
(a) MODIFY TABLE (b) DROP TABLE
(c) CHANGE TABLE (d) ALTER TABLE
9 Which of the following statement(s) would give an error after 1
executing the following code?
x= int("Enter the Value of x:")) #Statement 1
for y in range[0,21]: #Statement 2
if x==y: #Statement 3
print (x+y) #Statement 4
else: #Statement 5
print (x-y) # Statement 6
(a) Statement 4 (b) Statement 5
(c) Statement 4 & 6 (d) Statement 1 & 2
10 Fill in the blank: 1
For each attribute of a relation, there is a set of permitted values,
called the _______of that attribute.
(a) cardinality (b) degree (c) domain (d) tuple
11 What is the significance of the tell() method? 1
(a) tells the path of the file.
(b) tells the current position of the file pointer within the file.
(c) tells the end position within the file.
(d) checks the existence of a file at the desired location.
12 Fill in the blank: 1
The SELECT statement when combined with __________ clause,
returns records in sorted order.
(a) SORT (b) ARRANGE (c) ORDER BY (d) SEQUENCE
13 Fill in the blank: 1
The _______ is a mail protocol used to retrieve mail from a remote
server to a local email client.
(a) VoIP (b) FTP (c) PPP (d) HTTP
14 Evaluate the following Python expression 1
print(12*(3%4)//2+6)
(a)12 (b)24 (c) 10 (d) 14
15 In SQL, the aggregate function used to calculate and display the 1
average of numeric values in an attribute of a relation is:
(a) sum() (b) total() (c) count() (d) avg()
16 The name of the module used to establish a connection between 1
Python and SQL database is-
(a) mysql-connect (b) mysql-connector
(c) mysql-interface (d) mysql-conn
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):- The default arguments can be skipped in the function 1
call.
Reasoning (R):- The function argument will take the default values
even if the values are supplied in the function call
18 Assertion (A):- If a text file already containing some text is opened in 1
write mode the previous contents are overwritten.
Reasoning (R):- When a file is opened in write mode the file pointer is
present at the beginning position of the file
SECTION B
19 Aarti has written a code to input an integer and check whether it is 2
even or odd. The code has errors. Rewrite the code after removing all
the syntactical errors, underlining each correction:
checkval def():
x = input("Enter a number")
if x % 2 == 0
print (x, "is even")
else;
print (x, "is odd")
20 What is the difference between hub and switch? Which is more 2
preferable in a large network of computers and why?
OR
Differentiate between WAN and MAN. Also give an example of WAN.
21 (a) Given is a Python string declaration: 2
str="Kendriya Vidyalaya Sangathan"
Write the output of: print(str[9:17])
(b) Write the output of the code given below:
lst1 = [10, 15, 20, 25, 30]
lst1.insert( 3, 4)
lst1.insert( 2, 3)
print (lst1[-5])
22 What are constraints in SQL? Give two examples. 2
23 (a) Write the full forms of the following: 2
(i) TCP (ii) VPN
(b) What is the use of FTP?
24 Predict the output of the Python code given below: 2
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)
OR
Predict the output of the Python code given below:
a=20
def call():
global a
b=20
a=a+b
return a
print(a)
call()
print(a)
25 What are aggregate functions in MySql? Give their names along with 2
their use.
OR
List various DDL and DML commands available in MySql
SECTION C
26 (a) Consider the following tables – EMPLOYEES AND 1
DEPARTMENT
What will be the output of the following statement?
SELECT ENAME, DNAME FROM EMPLOYEES, DEPARTMENT
WHERE EMPLOYEE.DNO=DEPARTMENT.DNO;
(b) Write the output of the queries (i) to (iv) based on the tables given 2
below:

i) SELECT ITEM_NAME, MAX(PRICE), COUNT(*) FROM ITEM


GROUP BY ITEM_NAME;
ii) SELECT CNAME, MANUFACTURER FROM ITEM, CUSTOMER
WHERE ITEM.ID=CUSTOMER.ID;
iii) SELECT ITEM_NAME, PRICE*100 FROM ITEM WHERE
MANUFACTURER="ABC";
(iv) SELECT DISTINCT CITY FROM CUSTOMER;
27 Write a function in python to count the number of lines in a text file 3
‘Country.txt’ which are starting with an alphabet ‘W’ or ‘H’.
For example, If the file contents are as follows:
Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.
The output of the function should be:
W or w : 1
H or h : 2
OR
Write a user defined function to display the total number of words
present in a text file 'Quotes.txt'
For example if the file contents are as follows:
Living a life you can be proud of doing your best Spending your time
with people and activities that are important to you Standing up for
things that are right even when it’s hard Becoming the best version of
you.
The countwords() function should display the output as:
Total number of words : 40
28 (a) Write the outputs of the SQL queries (i) to (iv) based on the 2
relations SCHOOL and ADMIN given below:

(i) SELECT SUM (PERIODS), SUBJECT FROM SCHOOL GROUP


BY SUBJECT;
(ii) SELECT TEACHERNAME, GENDER FROM SCHOOL, ADMIN
WHERE DESIGNATION = ‘COORDINATOR’ AND
SCHOOL.CODE=ADMIN.CODE;
(iii) SELECT COUNT (DISTINCT SUBJECT) FROM SCHOOL;
(iv) SELECT MAX(PERIODS) FROM SCHOOL;
1
(b) Write the command to view the structure of a table SCHOOL
29 Write a function in python named SwapHalfList(Array), which accepts 3
a list Array of numbers and swaps the elements of 1st Half of the list
with the 2nd Half of the list, ONLY if the sum of 1st Half is greater
than 2nd Half of the list.
Sample Input Data of the list
Array= [ 100, 200, 300, 40, 50, 60],
Output Array = [40, 50, 60, 100, 200, 300]
30 Write a function in Python PushBook(Book) to add a new book entry 3
as book_no and book_title in the list of Books , considering it to act as
push operations of the Stack data structure.
OR
Write a function in Python PopBook(Book), where Book is a stack
implemented by a list of books. The function returns the value deleted
from the stack.
SECTION D
31 Rehaana Medicos Center has set up its new center in Dubai. It has
four
buildings as shown in the diagram given below:

Distances between various buildings are as follows:

No of Computers

As a network expert, provide the best possible answer for the


1
following
queries: 1
i) Suggest a cable layout of connections between the buildings.
ii) Suggest the most suitable place (i.e. buildings) to house the server 1
of
1
this organization.
iii) Suggest the placement of the Repeater device with justification. 1
iv) Suggest a system (hardware/software) to prevent unauthorized
access to or from the network.
(v) Suggest the placement of the Hub/ Switch with justification.
32 (a) Write the output of the code given below: 2
x = 50
def func():
global x
print('x is', x)
x = 20
print('Changed global+local x to', x)
func()
(b) The code given below inserts the following record in the table 3
Book:
B_No – integer
B_Name – string
B_Author – string
Price – Decimal
Note the following to establish connectivity between Python and
MYSQL:
▪ Username is root
▪ Password is tiger
▪ The table exists in a MYSQL database named Library.

The details (B_No, B_Name, B_Author and Price) are to be accepted


from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the
table Book.
Statement 3- to add the record permanently in the database
import mysql.connector as mysql
def sql_data():
conn=mysql.connect(host="localhost", user="root",
password="tiger", database="Library")
mycursor=_________________ #Statement 1
B_No=int(input("Enter Book Number : "))
B_Name=input("Enter Book Name : ")
B_Author=input("Enter Author : ")
Price=float(input("Enter Price : "))
sql="insert into Book values({},'{}','{}',{})".format(B_No, B_Name,
B_Author, Price)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")
conn.close()

OR
(a) Predict the output of the code given below:
def convert(Old):
l=len(Old)
New=" "
for i in range(0,1):
if Old[i].isupper():
New=New+Old[i].lower()
elif Old[i].islower():
New=New+Old[i].upper()
elif Old[i].isdigit():
New=New+"*"
else:
New=New+"%"
return New
Older="InDIa@2022"
Newer=Convert(Older)
print("New String is: ", Newer)
(b) The code given below reads and fetches all the records from EMP
table having salary more than 25000.
empno - integer,
ename- string and
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 company.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those
employees having salary more than 25000.
Statement 3- to read the complete result of the query (records whose
salary is more than 25000) into the object named data, from the table
EMP in the database.

import mysql.connector as mysql


def sql_data():
conn=mysql.connect(host="localhost", user="root", password=
"tiger", database="company")
mycursor=______________ #Statement 1
print("Employees with salary more than 25000 are : ")
try:
______________________________ #Statement 2
resultset=_____________________ #Statement 3
for row in resultset:
print(row)
except:
print("Error: unable to fetch data")
conn.close()
33 A binary file “Book.dat” has structure [BookNo, Book_Name, Author, 5
Price].
i. Write a user defined function CreateFile() to input data for a record
and add to Book.dat .
ii. Write a function CountRec(Author) in Python which accepts the
Author name as parameter and count and return number of books by
the given Author are stored in the binary file “Book.dat”

OR
A binary file “STUDENT.DAT” has structure (admission_number,
Name, Percentage). Write a function countrec() in Python that would
read contents of the file “STUDENT.DAT” and display the details of
those students whose percentage is above 75. Also display number
of students scoring above 75%
SECTION E
34 Modern Public School is maintaining fees records of students. The
database administrator Aman decided that-
• Name of the database -School
• Name of the table – Fees
• The attributes of Fees are as follows:
Rollno - numeric
Name – character of size 20
Class - character of size 20
Fee – Numeric
Qtr – Numeric
Answer any four from the following questions:
(i) Identify the attribute best suitable to be declared as a primary key 1
(ii) What is the degree of the table. 1
(iii) Write the statements to:
a. Insert the following record into the table 2
Rollno-1201, Name-Akshay, Class-12th, Fee-350, Qtr-2
b. Increase the second quarter fee of class 12th students by 50

OR (Option for part iii only)


a. Delete the record of student with Rollno-1212
b. Aman wants to add a new column to the Fees table,
Which command will he use from the following:
a) CREATE
b) ALTER
c) SHOW
d) DESCRIBE
35 Vijay of class 12 is writing a program to create a CSV file
“mydata.csv” which will 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.
import _____________ # Line 1
def addCsvFile(UserName,PassWord): # write data into the CSV
file
f=open(' mydata.csv','________') # Line 2
newFileWriter = csv.writer(f)
newFileWriter.writerow([UserName,PassWord])
f.close()
def readCsvFile(): # read data from CSV file
with open('mydata.csv','r') as newFile:
newFileReader = csv._________(newFile) # Line 3
for row in newFileReader:
print (row[0],row[1])
newFile.______________ # Line 4
addCsvFile(“Aman”,”123@456”)
addCsvFile(“Vijay”,”aru@nima”)
addCsvFile(“Raju”,”myname@FRD”) 1
readCsvFile()
(i) Give Name of the module he should import in Line 1. 1
(ii) In which mode, Vijay should open the file to add data into the file in
Line2. 2
(iii) Complete the Line 3 to read the data from csv file and Line 4 to
close the file.
Sample Paper 20
Computer Science (083)
CLASS XII 2023-24
Maximum Marks: 70 Time Allowed: 3 hours
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q34
against part C only.
8. All programming questions are to be answered using Python Language only.

SECTION A

1 What will be the result of the following statements? 1


a) bool(int(„0‟)) b) type(“hello”)
2 Which of the following is valid arithmetic operator in Python: 1
(a) // (b) ? (c ) < (d) and
3 Given the following dictionary 1
Emp1={„salary‟:10000,‟dept‟:‟sales‟,‟age‟:24,‟name‟:‟john‟}
Emp1.keys() can give the output as
a. („salary‟,‟dept‟,‟age‟,‟name‟)
b. [„name‟,„salary‟,‟dept‟,‟age‟]
c. [10000,‟sales‟,24,‟john‟]
d. {„salary‟,‟dept‟,‟age‟,‟name‟}

4 Consider the given expression: 1


(5<10)and(10<5)or(3<18)and not(8<18)
Which of the following will be correct output if the given expression is evaluated?

(a) True
(b) False
(c) NONE
(d) NULL
5 string= "it goes as - ringa ringa roses" 1
sub="ringa"
string.find(sub,15,22)
(a) 13 (b)-13 (c) -1 (d) 19
6 When the file content is to be retained , we can use the ____________ mode 1
(a) r (b) w (c) a (d) w+

7 Which of the following is NOT a DML Command? 1

(a) Insert (b) Update (c) Drop (d) Delete


8 Identify the error in the following SQL query which is expected to delete all rows of a table emp 1
without deleting its structure and write the correct one:

(a) DELETE TABLE emp;


(b) DROP TABLE emp;
(c) REMOVE TABLE emp;
(d) DELETE FROM emp;
9 What will be the Output for the following code – 1
Language=["C", "C++", "JAVA", "Python", "VB", "BASIC", "FORTRAN"]
del Language[4]
Language.remove("JAVA")
Language.pop(3)
print(Language)

(a) ['C', 'C++', 'VB', 'FORTRAN']


(b) ['C', 'C++', 'Python', 'FORTRAN']
(c) ['C', 'C++', 'BASIC', 'FORTRAN']
(d) ['C', 'C++', 'Python', 'BASIC']
10 All attribute combinations inside a relation that can serve as primary key are _______________ 1
(a) Primary Key
(b) Foreign Key
(c) Candidate Key
(d) Alternate Key
11 Which of the following statements correctly explain the function of tell() method? 1
(a) tells the current position within the file.
(b) tell the name of file.
(c) move the current file position to a different location.
(d) it changes the file position only if allowed to do so else returns an error

12 Which is known as range operator in MySQL? 1


(a) IN (b) BETWEEN (c) IS (d) DISTINCT
13 Network in which every computer is capable of playing the role of a client, or a server or both at same time 1
is called
a) local area network
b) peer-to-peer network
c) dedicated server network
d) wide area network
14 What will be the value of y when following expression be evaluated in Python? 1
x=10.0
y=(x<100.0) and x>=10
(a)110 (b) False (c)Error (d)True
15 All aggregate functions except _______ ignore null values in their input collection. 1
(a) Count (attribute)
(b) Count (*)
(c) Avg
(d) Sum
16 A database ___________is a special control structure that facilitates the row by row processing of 1
records in the result set.
(a) Fetch (b) table (c) cursor (d) query
Q17and 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):-Built in functions are predefined in the language that are used directly. 1
Reasoning(R):-print() and input() are built in functions
18 Assertion (A):CSV file stands for Comma Separated Values. 1
Reason(R):CSV files are common file format for transferring and storing data
SECTIONB

19 Ravi has written a function to print Fibonacci series for first 10 elements. His code is having 2
errors. Rewrite the correct code and underline the corrections made. some initial elements of
Fibonacci series are:

def fibonacci()
first=0
second=1
print((“first no. is “, first)
print(“second no. is , second)
for a in range (1,9):
third=first+second
print(third)
first,second=second,third
fibonacci()
20 Give difference between Video Conferencing and Chatting 2
OR
Write two points of difference between Message Switching and Packet Switching

21 (a) Given is a Python string declaration: 1


str="malayalam"
Write the output of print(str[ : :-1])

(b) Write the output of the code given below:


Employee1={'name':'John','salary':10000,'age':24}
1
Employee2={'name':'Divya','salary':54000,'dept':'Sales'}
Employee1.update(Employee2)
print(Employee1)

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)GSM (ii)XML
(b) What is the use of Modem?
24 (a) Predict the output of the Python code given below: 2

def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('Fun@World2.0')

OR
(b)Predict the output of the Python code given below:

What is the output of the following Python code


x=”hello world”
print(x[:2],x[:-2],x[-2:])
print(x[6],x[2:4])
print(x[2:-3],x[-4:-2])
25 Differentiate between WHERE and HAVING clause in MySql. 2
OR
What do you understand by the terms Degree, cardinality of a Relation? Explain with an example.

SECTION –C
26 (a) Differentiate between Natural join and Equi join. 1+2
(b)Table : Employee
EmployeeId Name Sales JobId
E1 SumitSinha 110000 102
E2 Vijay Singh 130000 101
Tomar
E3 Ajay Rajpal 140000 103
E4 Mohit Kumar 125000 102
E5 Sailja Singh 145000 103
Table: Job
JobId JobTitle Salary
101 President 200000
102 Vice President 125000
103 Administrator Assistant 80000
104 Accounting Manager 70000
105 Accountant 65000
106 Sales Manager 80000
Give the output of following SQL statement:
(i) Select Name, JobTitle, Sales from Employee, Job
where Employee.JobId=Job.JobId and JobId in (101,102);
(ii) Select JobId, count(*) from Employee group by JobId;

27 Write a method/function COUNT_BLANK_SPACES() in Python to read lines from a text file 3


STORY.TXT, and display the count of blank spaces in the text file.
OR
Write a method/function DISPLAYWORDS() in python to read lines from a text file POEM.TXT, and
display those words, which are less than 4 characters.

28 (a) Consider the following table GAMES. Give outputs for SQL queries (i) to (iv). 3
Table: GAMES
GCode GameName Number PrizeMoney ScheduleDate
101 CaromBoard 2 5000 23-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 TableTennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 LawnTennis 4 25000 19-Mar-2004

(i) SELECT COUNT(DISTINCT Number) FROM GAMES;


(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(iii) SELECT SUM(PrizeMoney) FROM GAMES;
(iv) SELECT * FROM GAMES WHERE PrizeMoney > 12000;

(b) What are the eligible candidate keys from the Table Games?

29 Write definition of a method/function DoubletheOdd( ) to add and display twice of odd values from 3
the list of Nums.
For example :
If the Nums contains [25,24,35,20,32,41]
The function should display
Twice of Odd Sum: 202
30 Pramod has created a dictionary containing EMPCODE and SALARY as key value pairs of 5 Employees of 3
Parthivi Constructions.
Write a program, with separate user defined functions to perform the following operations:
● Push the keys (Employee code) of the dictionary into a stack, where the corresponding value (Salary) is
less than 25000.
● Pop and display the content of the stack. For example: If the sample content of the dictionary is as follows:

EMP={"EOP1":16000, "EOP2":28000, "EOP3":19000, "EOP4":15000, EOP5":30000}


The output from the program should be: EOP4 EOP3 EOP1
OR

Write a function POP(Arr) , where Arr is a stack implemented by a list of numbers The function returns the
value deleted from the stack.

SECTION D

31 Quick Learn University is setting up its academic blocks at Prayag Nagar and planning to set up a
network. The university has 3 academic blocks and one human resource Centre as shown in the
diagram given below:

Business Technology
Block Block

Law Block HR Centre

Centre-to-Centre distance between various blocks is as follows:


Law block to business block 40 m
Law block to technology block 80 m
Law block to HR block 105 m
Business block to technology block 30 m
Business block to HR block 35 m
Technology block to HR block 15 m

Number of computers in each of the buildings is as follows:


Law block 15
Technology block 40
HR Centre 115
Business block 25
(a) Suggest a cable layout of connection between the blocks.
1
(b) Suggest the most suitable place to house the server of the organization with suitable reason. 1
(c) Which device should be placed/installed in each of these blocks to efficiently connect all the
1
computers within these blocks?
(d) The university is planning to link its sales counters situated in various parts of the CITY. Which
1
type of network out of LAN, MAN or WAN will be formed?
1
(e) Which network topology may be preferred between these blocks?
32 (a) Find and write the output of the following python code: 2+3
def Change(P ,Q=10):
P=P*Q
Q=Q+P
print( P,"#",Q)
return (Q)
A=5
B=10
A=Change(A)
B=Change(A,B)
print(A,"#",B)
(b) Avni is trying to connect Python with MySQLfor 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 and write the output of the following python code:
def encrypt(s):
k=len(s)
m=""
for i in range(0,k):
if(s[i].isupper( )):
m=m+str(i)
elif s[i].islower( ):
m=m+s[i].upper()
else:
m=m+'*'
print(m)
encrypt('Kvs@Hyderabad')
(b)Note the following to establish connectivity between Python and MYSQL:
 Username is myusername
 Password is mypassword
 The table exists in a MYSQL database named mydatabase
Write the following missing statements to complete the code:
Statement 1 – to create the connection object
Statement2–tocreate the cursor object
Statement3-To execute the sql query
import mysql.connector
mydb = _____________________________ # Statement 1
mycursor = _______________ # Statement 2
sql = "INSERT INTO customers (name, address) VALUES (%s, %s)"
val = ("John", "Highway 21")
mycursor._________________ # Statement 3
mydb.commit()
print(mycursor.rowcount, "record inserted.")
33 Manoj Kumar of class 12 is writing a program to create a CSV file “user.csv” which will contain
5
user name and password for some entries. He has written the following code. As a programmer,
help him to successfully execute the given task.
import ______________ #Line1
def addCsvFile(UserName, Password):
fh=open('user.csv','_____________') #Line2
Newfilewriter=csv.writer(fh)
Newfilewriter.writerow([UserName,Password])
fh.close( )
# csv file reading code
def readCsvFile(): #to read data from CSV file
with open('user.csv','r') as newFile:
newFileReader=csv.______(newFile) #Line3
for row in newFileReader:
print(row)
newFile.________________ #Line4
addCsvFile('Arjun','123@456')
addCsvFile('Arunima','aru@nima')
addCsvFile('Frieda','myname@FRD')
readCsvFile()
OUTPUT___________________ #Line 5
(a) What module should be imported in #Line1 for successful execution of the program?
(b) In which mode file should be opened to work with user.csv file in#Line2
(c) Fill in the blank in #Line3 to read data from csv file
(d) Fill in the blank in #Line4 to close the file
(e) Write the output he will obtain while executing Line5
OR
Radha Shah is a programmer, who has recently been given a task to write a python code to perform
the following CSV file operations with the help of two user defined functions/modules:

(a) . CSVOpen() : to create a CSV file called “ books.csv” in append mode containing
information of books – Title, Author and Price.
(b). CSVRead() : to display the records from the CSV file called “ books.csv” .where the field
title starts with 'R'.
She has succeeded in writing partial code and has missed out certain statements, so she has left
certain queries in comment lines.
import csv
def CSVOpen( ):
with open('books.csv','______',newline='') as csvf: #Statement-1
cw=______ #Statement-2
______ #Statement-3
cw.writerow(['Rapunzel','Jack',300])
cw.writerow(['Barbie','Doll',900])
cw.writerow(['Johnny','Jane',280])
def CSVRead( ):
try: with open('books.csv','r') as csvf:
cr=______ #Statement-4
for r in cr:
if ______: #Statement-5
print(r)
except:
print('File Not Found')
CSVOpen( )
CSVRead( )

You as an expert of Python have to provide the missing statements and other related queries based
on the following code of Radha.
(a) Write the appropriate mode in which the file is to be opened in append mode (Statement 1)
(b) Which statement will be used to create a csv writer object in Statement 2.
(c) Write the correct option for Statement 3 to write the names of the column headings in the CSV
file, books.csv
(d) Write statement to be used to read a csv file in Statement 4.
(e) Fill in the appropriate statement to check the field Title starting with „R‟ for Statement 5 in the
above program.

SECTION –E
34 A departmental store MyStore is considering to maintain their inventory using SQL to store the 1+1+
data. As a database Administrator, Abhay has decided that: 2
Name of the database – mystore
Name of the table –STORE
The attributes of STORE are as follows
ItemNo –numeric
ItemName – character of size 20
Scode – numeric
Quantity – numeric

Table : STORE
ItemNo ItemName Scode Quantity

2005 Sharpner Classic 23 60


2003 Ball Pen 0.25 22 50
2002 Gel Pen Premium 21` 150
2006 Gel Pen Classic 21 250
2001 Eraser Small 22 110
2004 Eraser Big 22 220
2009 Ball Pen 0.5 21 180

(a) Identify the attribute best suitable to be declared as primary key


(b) Write the query to add the row with following details
(2010,”Notebook”,23,155)
(c) (i) Abhay wants to remove the table STORE from the database MyStore, Help Abhay in writing
the command for removing the table STORE from the database MyStore.
(ii) Now Abhay wants to display the structure of the table STORE i.e. name of the attributes
and their respective data types that he has used in the table. Write the query to display the
same.
OR
(i) Abhay wants to ADD a new column price with data type as decimal. Write the query to add
the column..
(ii) Now Abhay wants to remove a column price from the table STORE. Write the query.

35 Manoj is learning to work with Binary files in Python using a process known as Pickling/de-
pickling. His teacher has given him the following incomplete code, which is creating a Binary file
namely Mydata.dat and then opens, reads and displays the content of this created file.

import____________#Statement-1
sqlist=list()
for k in range(5): sqlist.append(k*k)
fout=open(“mydata.dat”,____________) #Statement-2
_____________(sqlist,fout) #Statement-3
fout.close()
fin=open(“Mydata.dat”, “rb” )
mylist= _________________(fin) #Statement-4
fin.close()
print(mylist)

1
i) Which module should be imported in Statement-1.
1
ii) Which file mode to be passed to write data in file in Statement-2
iii) What should be written in Statement-3 to write data onto the file. 1
iv) Which function to be used in Statement-4 to read the data from the file. 1
Sample Paper 21
Computer Science (083)
CLASS XII 2023-24

Time : 3 hours Maximum Marks:70


General Instructions
❖ This Question paper contains 14 printed pages.
❖ This Question paper contains 35 Questions.
❖ Write down the question number before attempting.
❖ An additional reading time of 15 minutes.
General Instruction to answer this Question paper
1. This Question paper contains Five Sections, Section A to E.
2. All Question are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer Type Questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in
Q34 against part (iii) only.
8. All Programming questions are to be answered using python language only.

SECTION A

1. Which of the following is an unordered collection of elements in python? 1


(a)List (b) Tuple (c) Dictionary (d) String

2. Identify the invalid variable name from the following. 1


Adhar@Number, none, 70outofseventy, mutable

3. Consider the coding given below and fill in the blanks: 1


Dict_d={‘BookName’:’Python’,’Author’:”Arundhati Roy”}
Dict_d.pop() # Statement 1
List_L=[“java”,”SQL”,”Python”]
List_L.pop() # Statement 2
(i) In the above snippet both statement 1 and 2 deletes the last element
from the object Dict_d and List_L________(True/False).
(ii) Statement_______(1/2) alone deletes the last element in its object.

4. Evaluate the following expression: 1


False and bool(15/5*10/2+1)

Page 1 of 14
5. Write the output for the following python snippet. 1
LST=[1,2,3,4,5,6]
for i in range(6):
LST[i-1]=LST[i]
print(LST)

6. Out of the following file mode which opens the file and delete all its contents 1
and place the file pointer at the beginning of the file.
(a) a (b) w (c) r (d) a+

7. (a) In an SQL table, if the primary key is combination of more than one 1
field, then it is called as _____________.
(b) _________ command is used to make an existing column as a primary
key.

8. In MYSQL state the commands used to delete a row and a column 1


respectively
(a) DELETE,DROP
(b) DROP,DELETE
(c) DELETE,ALTER
(d) ALTER,DROP

9. Debug the following code and underline the correction made: 1


d=dict{}
n=input("enter number of terms")
for i in range(n):
a=input("enter a character")
d[i]=a

10. In MYSQL _____ clause applies the condition on every ROW and ______ 1
clause applies the condition on every GROUP.

11. Complete the following snippet to open the file and create a writer object for 1
a csv file “emp.csv” with delimiter as pipe symbol ‘|’ to add 5 more records
into the file using the list named “e_rec”.
emp_file=___________
csv_writer=csv.writer( ____________ )

12. _________ Operator is used to compare NULL value in MYSQL table. 1


(a) = = (b) IN (c) IS (d) LIKE

Page 2 of 14
13. Name any two protocols used for video conferencing. 1

14. Write output for the following code: 1


list1=[x+2 for x in range(5)]
print(list1)

15. Which command is used to display the structure of the table? Write the 1
syntax of the command.

16. Which function of mysql.connector library lets you check if the connection 1
to the database is established or not?
(a) connectionobject.is_connected()
(b) mysql.connector,connect()
(c) mysql.connector()
(d) mysql.connector

Q17 and Q18 are ASSERTION and REASONING based questions.


Mark the correct choice as
(a) Both A and B 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) : 1
When we open the file in write mode the content of the file will be erased if
the file already exist.
Reasoning(R):
Open function will create a file if does not exist, when we create the file both
in append mode and write mode.

18. Assertion(A): 1
Keyword argument were the named arguments with assigned values being
passed in the function call.
Reasoning (R):
Default arguments cannot be skipped while calling the function while
keyword arguments are in function call statement.

SECTION B

19. Mr. Gupta wants to print the city he is going to visit and the distance to 2
reach that place from his native. But his coding is not showing the correct

Page 3 of 14
output debug the code to get the correct output and state what type of
argument he tried to implement in his coding.
def Travel(c,d)
print(“Destination city is “,city)
print(“Distance from native is “,distance)
Travel(distance=”18 KM”,city=”Tiruchi”)

20. What is meant by domain name? Give an example 2


OR
List any two difference between bridge and router.

21. Write the output for the following python code: 2


def Change_text(Text):
T=""
for K in range(len(Text)):
if Text[K].isupper():
T=T+Text[K].lower();
elif K%2==0:
T=T+Text[K].upper()
else:
T=T+T[K-1]
print(T)
Text="Good go Head"
Change_text(Text)

22. What is the difference between Equi join and Natural join? Give an Example 2

23. (a) Expand the following: 2


(i) IMAP (ii) HTTPS
(b) What is meant by interspace?

24. Write the output for the following python code: 2


def Quo_Mod (L1):
L1.extend([33,52])
for i in range(len(L1)):
if L1[i]%2==0:
L1[i]=L1[i] /5
else:

Page 4 of 14
L1[i]=L1[i]%10
L=[100,212,310]
print(L)
Quo_Mod(L)
print(L)
OR
What possible outputs are expected to be displayed on screen at the time of
execution of the program from the following code? Also specify the
maximum value that can be assigned to each of the variables L and U.
import random
Arr=[10,30,40,50,70,90,100]
L=random.randrange(1,3)
U=random.randrange(3,6)
for i in range(L,U+1):
print(Arr[i],"@",end="")
(i) 40 @50 @ (ii) 10 @50 @70 @90 @
(iii) 40 @50 @70 @90 @ (iv) 40 @100 @

25. What is the difference between column constraint and table constraint? Give 2
an example.
OR
What is the difference between LIKE and IN operator in MYSQL. Give an
example.

SECTION C

26. (a) Consider the following tables FACULTY and STUDENT. Write the 3
output for the MYSQL statement given below and state what type of join
is implemented.
SELECT * FROM FACULTY,STUDENT

FACULTY STUDENT

Faculty_Id Name
Stu_id Stu_Name
F100 Govardhan
12101 Anitha
F101 Janet
12102 Vishnu
F102 Rithu

Page 5 of 14
(b) Write the output for the queries (i) to (iv) based on the table given
below.
SPOTRS

S_ID SNAME FEES START_DT No_of_Players

S1 Foot Ball 5000 2015-01-10 25

S2 Basket Ball 4000 2016-10-10 30

S3 Volley Ball 5000 2017-02-02 25

S4 Kho-Kho 5500 2017-03-20 40

S5 Basket Ball 6000 2016-02-15 50

(i) SELECT MAX(FEES),MIN(FEES) FROM SPORTS.


(ii) SELECT COUNT(DISTINCT SNAME) FROM SPORTS.
(iii) SELECT SNAME,SUM(No_of_Players) FROM SPORTS
GROUP BY SNAME.
(iv) SELECT AVG(FEES*No_of_Players) FROM SPORTS WHERE
SNAME=”Basket Ball”.

27. Write a function named COUNT_CHAR() in python to count and display 3


number of times the arithmetic operators(+,-,*,/) appears in the file
“Math.txt” .
Example:
Solve the following:
1.(A+B)*C/D
2.(A-B)*(A+B)/D-(E/F)
3. A+B+C/D*(E/F)
The function COUNT_CHAR() must display the output as
Number of ‘+’ sign is 4
Number of ‘-‘ sign is 2
Number of ‘*’ sign is 3
Number of ‘/’ sign is 5
OR
Write a function V_COUNT() to read each line from the text file and count
number of lines begins and ends with any vowel.

Page 6 of 14
Example:
Eshwar returned from office and had a cup of tea.
Veena and Vinu were good friends.
Anusha lost her cycle.
Arise! Awake! Shine.
The function must give the output as:
Number of Lines begins and ends with a vowel is 3

28. (a) Write the SQL Queries for (i) to (iii) based on the table EMPLOYEE 3
and DEPARTMENT.
EMPLOYEE

EMP_ID Name DEPT JOIN_DT SALARY

E1 Vanitha 101 2015-01-01 50000

E2 Karthika 102 2015-02-01 75000

E3 Prathiba 103 2014-01-05 85000

E4 Mihika 101 2016-06-10 100000

E5 Mridula 102 2014-10-15 95000

DEPARTMENT

DEPT_ID D_NAME

101 Production

102 Sales

103 Marketing

(i) To display department name and number of employees in each


department where no of employees is greater than one.
(ii) To display department name and sum of the salary spent by the
department, where the total amount spent by the department as
salary is more than 100000.
(iii) To display the name of the employee in descending order of their
seniority.

Page 7 of 14
29. Write a function DIVI_LIST() where NUM_LST is a list of numbers passed 3
as argument to the function. The function returns two list D_2 and D_5 which
stores the numbers that are divisible by 2 and 5 respectively from the
NUM_LST.
Example:
NUM_LST=[2,4,6,10,15,12,20]
D_2=[2,4,6,10,12,20]
D_5=[10,15,20]

30. Mohammed has created a dictionary containing names and marks of 3


computer science as key, value pairs of 5 students. Write a program, with
separate user defined functions to perform the following operations:

● Push the keys (name of the student) of the dictionary into a stack, where
the corresponding value (CS marks) are more than or equal to 90 .

● Pop and display the content of the stack, if the stack is empty display the
message as “UNDER FLOW”
For example: If the sample content of the dictionary is as follows:
CS={"Raju":80, "Balu":91, "Vishwa":95, "Moni":80, “Govind":90}
The push operatio’s output from the program should be:
Balu Vishwa Govind
The pop operation must display
Govind
Vishwa
Balu
“UNDER FLOW”
OR
Dev Anand have a list of 10 numbers. You need to help him create a program
with separate user defined functions to perform the following operations
based on this list.
● Traverse the content of the list and push the numbers divisible by 5 into
the stack.
● Pop and display the content of the stack, if the stack is empty display the
message” STACK EMPTY”
For Example:
If the sample Content of the list is as follows:
N=[2,5,10,13,20,23,45,56,60,78]
After the push operation the list must contain

Page 8 of 14
5,10,20,45,60
And pop operation must display the output as
60
45
20
10
5
STACK EMPTY

31. A professional consultancy company is planning to set up new offices in 5


India with its hub at Chennai. As a network adviser, you have to understand
their requirements and suggest to them the best available solutions.

Distance between Blocks in (Mtrs)

Human Resources - Conference 60

Human Resources - Finance 60

Conference - Finance 120

Expected Number of Computers to be installed in each block:

Block Computers

Human Resources 125

Conference 25

Finance 60

Page 9 of 14
(a) Suggest the most appropriate block where the organization should plan
to install their server?
(b) Draw a block-to-block cable layout to connect all the buildings in the
most appropriate manner for efficient communication.
(c) What will be the best possible connectivity out of the following to
connect the new set-up of offices in Chennai with its London base office?
(i) Infrared (ii) Satellite Link (iii) Ethernet Cable
(d) Which of the following devices will you suggest to connect each
computer in each of the above buildings?
(i) Gateway (ii) Switch (iii) Modem
(e ) Suggest a device/software to be installed for data security in the campus.

32. (a) Find the output for the following python code: 2+3

def LST_ARG(L1):
L2=L1
L3=[0,0,0,0]
print("L2->",L2)
print("L3->",L3)
j=0
L1.append(51)
for i in range(len(L1)):
if L1[i]%5==0:
L2[j]=L2[j]*L2[j]
L3[j]=L2[j]%5
j+=1
print("L1->",L1)
print("L2->",L2)
print("L3->",L3)

L1=[10,15,20]
LST_ARG(L1)
print("L1->",L1)

(b) The Python program establishes connection between python and mysql,
and display the students details where the marks were between 80 to 90.
Write the missing statement to complete the code.

Page 10 of 14
Statement 1 – to check whether connection is not established.
Statement 2 – to create cursor object.
Statement 3 – to retrieve all the data from the cursor object.

import mysql.connector
conn=mysql.connector.connect(host="localhost",user="root",passwd="123
45",database="student")
if______________ # Statement 1
print("Error connecting to MYSQL DATABASE")
________________ # Statement 2
c.execute("select * from student where marks>80 and marks<90")
_____________ # Statement 3
count=c.rowcount
print("total no of rows:",count)
for row in r:
print(row)
OR
(a) Find the output for the following python code :

def OUTER(Y,ch):
global X,NUM
Y=Y+X
X=X+Y
print(X,"@",Y)
if ch==1:
X=inner_1(X,Y)
print(X,"@",Y)
elif ch==2:
NUM=inner_2(X,Y)
def inner_1(a,b):
X=a+b
b=b+a
print(a,"@",b)
return a
def inner_2(a,b):
X=100

Page 11 of 14
X=a+b
a=a+b
b=a-b
print(a,"@",b)
return b
X=100
NUM=1
OUTER(NUM,1)
OUTER(NUM,2)
print(NUM,"@",X)

(b) Consider the following Python code is written to access the details of
employee, whose employee number is given:
Complete the missing statements:
Statement 1 – To create a cursor object to execute the query.
Statement 2 – To execute the query stored in the variable change.
Statement 3 – To make the changes in the database physically.
def Search():
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",
passwd="system",database="DB")
_______________ # Statement 1
change="update employee set salary=salary+5000 where empno=
1011"
_______________ # Statement 2
______________ # Statement 3
results = mycursor.fetchall()
print(results)

33. What is the use of seek() function ? Write a python program that defines and 5
calls the following user defined functions.
Add_book() – To read the details of the books from the user and write into
the csv file named “book.csv”. The details of the books stored in a list are
book_no,name,author.
Search_book() - To read the author name from the user and display the books
written by the author.
OR

Page 12 of 14
How to open the file using with statement? Write a python program that
defines and calls the user defined functions given below.
Add_rating() – To read product name and rating from the user and store the
same into the csv file “product.csv”
Display() – To read the file “product.csv” and display the products where the
rating is above 10.

SECTION E

34. Naveen created a table SALES_DONE to maintain the sales made by his
sales department. The table consists of 10 employees records. To record 1+1+2
every months sales he is adding a new column with first three characters of
that month.

EMP_NO NAME ACCT_NO Jan Feb

101 Naren Kumar 105231 150 300

102 Jaya Deep 510423 120 140

103 Naveen Kumar 20146 210 250

104 Srinikethan 698751 210 140

105 Tharun Venkat 564132 220 230

Based on the above table answer the following questions:


(i) Identify the candidate key, primary key from the above table.
(ii) He added two more employee in the month of February and if a new
column is added for each month, at the end of May month what is the degree
and cardinality of the table.
(iii) Write the SQL statement to do the following
(a) Insert the following record into the above table.
106,”Venkatesh Gour”,256489,200,300
(b) Change the name of the employee as Sri Nikethan” whose emp no is
104.
OR (option for part iii only)
(iii) Write the MYSQL statement for the following
(a) Add a new column Total_sales of type integer with NOT NULL
constraint.
(b) Fill the column Tot_sales by adding values in Jan and Feb columns.

Page 13 of 14
35. Mrs.Renu wrote a python program to update the salary of the employee by 4
reading the employee number. She got some errors while executing the
program so she deleted those lines. As a python programmer guide her to fill
the missing statements.
_____________ # Statement 1
def modify():
e=[ ]
____________ # Statement 2
found=False
T_eno=int(input("enter employee no"))
try:
while True:
____________ # Statement 3
e=pickle.load(f)
if e[0] == T_eno:
e[2]=float(input("enter new salary"))
f.seek(pos)
__________ # Statement 4
found=True
except:
f.close()
if found==True:
print("employee record found and updated")
else:
print("employee record not found and updating not possible")

(i) Write the statement to import the needed module.


(ii) Write the statement to open the file named “emp.bin” as per the
need of the code.
(iii) Write the statement to store the position of the file pointer.
(iv) Complete the blank with the statement to write the object “e” into
the file.

“End of Paper”

Page 14 of 14
Sample Paper 22
Computer Science (083)
CLASS XII 2023-24
GRADE:XII MARKS:70
SUBJECT: COMPUTER SCIENCE TIME: 3 HRS
General Instructions:
➢ The paper is divided into 4 Sections- A, B, C, D and E & contains 35 questions.
➢ Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
➢ Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
➢ Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
➢ Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
➢ Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
➢ All programming questions are to be answered using Python Language only.
Q. NO SECTION A MARKS

1. State True or False:


A dictionary key must be of a data type that is mutable. 1
2. Identify the appropriate data type for the attribute Date_of_Birth - 12/01/2004.
a) Timestamp b) varchar(11) c) Blob d) date 1
3 What will the following expression be evaluated to in Python?
print( ( - 33 // 13) * (35 % -2)* 15/3) 1
4 str="R and Data Science"
z=str.split() 1
newstr="=".join([z[2].upper(),z[3],z[2]+z[3],z[1].capitalize()])
newstr is equal to ____________________________

5 If a table AA in MySQL database is having 2 rows and 4 columns and the table BB is having
4 rows and 2 columns, the cartesian product of AA and BB will have degree and cardinality as 1
________________________.

6 Mr.Vivek Rana a network administrator of Rana Co. Ltd wants to connect his registered office
located in Mumbai with its head office in Delhi. Suggest an economic way to connect it with 1
reasonable high speed?

7. Find the output of the code:


S="eComPhyMat" 1
L=["C","a","r","e","e","r","F","a","i","r"]
D={}
for i in range(len(S)):
if i%2==0:
D[L.pop()]=S[i]
else:
D[L.pop()]=i+5
for x,y in D.items():
print(x,y,sep="#")

8 Consider the string, spstr="Next is #Rio in 24" Find the output of, spstr[-5:3:-2]. 1
9 Consider the Python statement, t=(10,20,30,40,50,60) Identify from the options below that
will result in an error. 1
a) t[4]+44 b) t[4]-44 c) t=t-(70,) d) t=t+(70,)

10 What possible output(s) are expected to be displayed on screen at the time of execution of the 1
program from the following code? Select correct options (can also choose more than one
option) from below.
import random
arr=['10','30','40','50','70','90','100']
L=random.randrange(1,3)
U=random.randrange(3,6)
for i in range(L,U+1):
print(arr[i],"$",end="@")
a) 30 $@40 $@50 $@70 $@90 b)30 $@40 $@50 $@70 $@90 $@
c) 30 $@40 $@70 $@90 $@ d) 40 $@50 $@

11 Which of the following is not a valid URL: 1


1. kvsangathan.nic.in 2. www.google.com
3. acad@google.com 4. http://cbseacademic.nic.in/curriculum_2022.html

a)1 & 3 b) 3 & 4 c) Only 3 d)Only 4

12 Identify the missing statement of the following python code if the output produced is 500: 1
a=100
def show( ):
global a
a=100
def invoke( ):
___________ # Missing statement
a=500
show( )
invoke( )
print(a)

13 Look at the code below and identify the type of exception that will be thrown from the options
arr=[10,20,30,40,50,60,70,80,90,100] 1
for i in range(len(arr)+1):
print(arr.pop())

14 Identify the False relational database statement from the options below.
a) Alternate key(s) are the Candidate key(s) not selected as Primary key. 1
b) Foreign key of a table is a Primary key of the table it points to.
c) There can be many Candidate keys in a table.
d) Referential Integrity is enforced by the Alternate keys.

15 Suryansh wants to upload and download files from / to a remote internal server. Write the
name of the relevant communication protocol, which will let him do the same. 1
16 The <filehandle>.seek( 8 ) if applied to a text file stream object moves the read cursor /
pointer : 1
a) 8 characters backwards from its current position
b) 8 characters backward from the end of the file
c) 8 characters forward from its current position
d) 8 characters forwarded from the beginning of the file

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 of A
b) Both A and R are true and R is not the correct explanation of A
c) A is True but R is False
d) A is false but R is True

17 Assertion (A): If L is a list, then L+=range(5) is an invalid statement. 1


Reason (R): Only a list can be concatenated to a list.

18 Assertion (A): The function definition calculate(a, b, c=1,d) will give error. 1
Reason (R): All the non-default arguments must precede the default arguments.

SECTION B

19 i) Expand the following: FTP & POP 2


ii) Write the difference between web server and web browser.
OR
i) How Hub is different from switch.
ii) Explain the 80-20 rule of network design?

20 The following code that consists of a function and user input part is supposed to return the
factors of a number supplied as a parameter. Since there are errors in both syntax and logical 2
errors it’s not showing the correct result. Your task is to identify and underline the errors.

def problem(n):
myList = ( )
for i in range(1, n+1):
if n // i =0:
myList.append(i)
return myLis
problem(4):

21 CBG is a dictionary that stores the name of the country and their respective Central Banks
Governor’s name as shown below. 2
CBG={"Germany":"JoachimNagel","France":"FrancoisVilleroy de Galhau",
"India":"ShaktikantaDas", "UnitedKingdom":"AndrewBailey",
"UnitedStates":"Jer ome Powell"}
Write a function getNames(CBG) that will take the dictionary as its parameter and will display
only those Governor’s names which are more than 20 characters long including the spaces in
between.
OR
Consider the string G20 below G20="African Union has been included as a member of the
G20". Write a function lenWords(G20) that takes the string as its parameter and returns the
length of each word of the string as a tuple.

22 Find the output of the following code:


s='UVW' 2
L=[10,20,30]
D={}
N=len(s)
for I in range(N):
D[L[I]]=s[I]
for k,v in D.items():
print(k,v,sep='*',end=',')

23 Write the Python statement for each of the following tasks using built-in functions / methods
only: 2
i) To add another alphabet ‘e’ after the alphabet ‘e’ in the list
L=["C","a","r","e","r","F","a","i","r"]
ii) Check if the string S="eComPhyMat" starts with the alphabet ‘e’.
OR
Determine the most frequent alphabet in the list L=["C","a","r","e","e","r","F","a","i","r"] by
importing appropriate module in Python

24 i) In the existing MySQL table admin with the fields code, gender, designation add the
primary key icode of integer type in the beginning. 2
ii) Ms. Shalini has just created a table named “Employee” containing columns
Ename, Department, Salary. After creating the table, she realized that she had forgotten to add
a primary key column in the table. Help her in writing SQL commands to add a primary key
column empid. Also state the importance of the Primary key in a table.
OR
From the MySQL table admin with the fields icode, code, gender, designation
i) drop the field designation
ii) add a new column department of varchar of any suitable size. Make sure it cannot remain a
blank entry.

25 Find the output of the following: 2


def anher(x,y=10):
x=x/y
y=x%y
return x
m=200
n=20
m=anher(m,n)
print(m,n,sep="#")
n=anher(n)
print(m,n,sep="#",end="$$$")

SECTION C

26 Predict the output of the following code given below:


s="welcome2kv" 3
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)

27 Consider the table itemmast below, write the output of the MySQL Queries.
3

itemno itemname stock itemprice suppdate

100 amul butter 500 gm 40 250 2023-09-17

101 amul butter 100 gm 60 50 2023-09-17

102 amul gold 1 litre 90 75 2023-09-16

103 amul paneer 50 85 2023-09-15


i) select count(distinct suppdate) from itemmast;
ii) select itemname, stock from itemmast where itemprice>100 and itemname like '%gm';
iii) select itemname, stock from itemmast where suppdate<'2023-09-17' and stock between 40
and 100;

28 Write a function to read data from a text file ‘DATA.TXT’, and display words which have a
maximum number of vowel characters. 3
OR
A text file contains alphanumeric text (say num.txt).Write a function read_digit () that reads
this text file and prints only the numbers or digits from the file.

29 Look at the table structure itemmast table and write the MySQL Queries: 3

Field Type Null Key Default Extra

itemno int NO PRI NULL

itemname varchar(30) YES NULL

stock int YES NULL

itemprice int YES NULL

suppdate varchar(20) YES NULL


i) Drop the primary key.
ii) Increase itemprice for each by 10%;
iii) Delete the records where itemprice is more than 200.
30 A list items contain the following record as list elements [itemno, itemname, stock]. Each of 3
these records are nested to form a nested list. Write the following user defined functions to
perform the following on a stack reorder
i) Push(items): It takes the nested list as its argument and pushes a list object containing
itemno and itemname where stock is less than 10.
ii) Popitems(): It pops the objects one by one from the stack reorder and also displays a .
message ‘Stack empty’ at the end.

SECTION D
31 Consider the following tables ITEM and CUSTOMER. Write the SQL command for the 4
following statements:
Table: ITEM
I_ID ItemName Manufacturer Price

PC01 Personal Computer ABC 35000

LC05 Laptop ABC 55000

PC03 Personal Computer XYZ 32000

PC06 Personal Computer COMP 37000

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 Sharma Delhi LC03

16 K agarwal Banglore PC01


i) To display the details of those customers whose City is Delhi.
ii) To display the details of an Item whose price is in the range of 35000 to 55000 (both values
to be included).
iii) To display the CustomerName, City from the table Customer & ItemName and Price from
the table Item with their corresponding matching I_ID.
iv) To increase the price of all items by 1000 in the table Item.

32 Radha Shah is a programmer, who has recently been given a task to write a python code to 4
perform the following CSV file operations with the help of two user defined
functions/modules:
a) CSVOpen() : to create a CSV file called “ books.csv” containing information about books
of 5 records – [Title, Author and Price] with the headings.
b) CSVRead() : to display the records from the CSV file called “ books.csv” .where the field
title starts with 'R'.
SECTION E

33 FutureTech Corporation, a Bihar based IT training and development company, is planning to 5


set up training centers in various cities in the coming year. Their first center is coming up in
Surajpur district. At Surajpur center, they are planning to have 3 different blocks - one for
Admin, one for Training and one for Development. Each block has a number of computers,
which are required to be connected in a network for communication, data and resource
sharing. As a network consultant of this company, you have to suggest the best network
related solutions for them for issues/problems raised in question nos. (i) to (v), keeping in
mind the distances between various blocks/locations and other given parameters.
Distance between various blocks / location:
Block Distance

Development to Admin 28 m

Development to Training 105 m

Admin to Training 32 m

Surajpur Campus to Coimbatore Campus 340 KM

Number of Computers:
Block Number of Computers

Development 90

Admin 40

Training 50

i) Suggest the most appropriate block/location to house the SERVER in the Surajpur center
(out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
ii) Suggest why should a firewall be installed at the Surajpur Center?
iii) Suggest the best wired medium and draw the cable layout (Block to Block) to most
efficiently connect various blocks within the Surajpur Center.
iv) Suggest the placement of the following devices with appropriate reasons:
a) Switch/Hub b) Router
v) Identify the type of network used to connect Surajpur Center and Raipur Center.
34 i) Write the importance of flush( ).
ii) Alia has been given a task of writing a code to create a binary file EMPLOYEE.DAT with 5
employeeid, ename and salary. The file contains 10 records. He now has to update a record
based on the employee id entered by the user and update the salary. The updated record is then
to be written in the file updateemp.dat. The records which are not to be updated also have to
be written to the file updateemp.dat. If the employee id is not found, an appropriate message
should be displayed. Write a user defined function update_data( ) to complete the above task.
OR
i) Explain the process of serialization in the Binary file.
ii)A binary file Book.dat has a structure [bookno,book_name,author,price].Write a function in
Python count_book() to count and return the no.of books whose price is between 100 and 500.

35 i) Are count (*) and count()the same functions? Why/why not?


ii) The code given below inserts the following record in the table Emp: 1+4=5
EmpNo – integer
EName – string
Desig – string
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username is admin
Password is 22admin66
The table exists in a MYSQL database named company.
The details (EmpNo, EName, Desig and Salary) are to be accepted from the user. Write the
program in Python to meet the above need.
OR

i) Give one point of difference between an equi-join and a natural join.


ii) Write the user defined function display ( ) in python to execute the query that fetches
records of the employees coming from the city ‘Delhi’.
E_code - string
E_name - String
Sal = Integer
City - string
Note the following to establish connectivity between Python and MySQL:
❖ Username is root
❖ Password is root
❖ The table exists in a MySQL database named emp.
❖ The details (E_code, E_name, Sal, City) are the attributes of the table.
Sample Paper 23
Computer Science (083)
CLASS XII 2023-24
GRADE:XII MARKS:70
SUBJECT: COMPUTER SCIENCE TIME: 3 HRS
General Instructions:
➢ The paper is divided into 4 Sections- A, B, C, D and E & contains 35 questions.
➢ Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
➢ Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
➢ Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
➢ Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
➢ Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
➢ All programming questions are to be answered using Python Language only.
Q. NO SECTION A MARKS

1. State True or False :


Python does not allow the same variable to hold different data literals / data types. 1
2. What should be the data type for the column Price storing values less than ₹1000, eg: 200.21?
a) varchar2(50) b) number c) number(5,2) d) number(6) 1
3 What will the following expression be evaluated to in Python?
print( ( - 33 // 13) * (35 % -2)* 15/3) 1
4 str="R and Data Science"
z=str.split() 1
newstr="=".join([z[2].upper(),z[3],z[2]+z[3],z[1].capitalize()])
newstr is equal to ____________________________

5 A table has initially 5 columns and 8 rows. Consider the following sequence of operations
performed on the table: 1
i) 8 rows are added
ii) 2 columns are added
iii) 3 rows are deleted
iv) 1 column is added
What will be the cardinality and degree of the table at the end of above operations?

6 Mr.Vivek Rana a network administrator of Rana Co. Ltd wants to connect his registered office
located in Mumbai with its head office in Delhi. Suggest an economic way to connect it with 1
reasonable high speed?

7. Given the following dictionaries:


dict_fruit={"Kiwi":"Brown", "Cherry":"Red"} 1
dict_vegetable={"Tomato":"Red", "Brinjal":"Purple"}
Which statement will merge the contents of both dictionaries?
a) dict_fruit.update(dict_vegetable) b) dict_fruit + dict_vegetable
c) dict_fruit.add(dict_vegetable) d) dict_fruit.merge(dict_vegetable)

8 Which output line(s) of the following program will print the same results?
tup1 = (10, 20, 30, 40, 50, 60, 70, 80, 90) 1
print(tup1[5:-1]) # Statement 1
print(tup1[5]) # Statement 2
print(tup1[5:]) # Statement 3
print(tup1[-4:8]) # Statement 4

9 Consider the Python statement, t=(10,20,30,40,50,60) Identify from the options below that
will result in an error 1
a) t[4]+44 b) t[4]-44 c) t=t-(70,) d) t=t+(70,)

10 What possible output(s) are expected to be displayed on screen at the time of execution of the 1
program from the following code? Select correct options (can also choose more than one
option) from below.
import random
arr=['10','30','40','50','70','90','100']
L=random.randrange(1,3)
U=random.randrange(3,6)
for i in range(L,U+1):
print(arr[i],"$",end="@")
a) 30 $@40 $@50 $@70 $@90 b)30 $@40 $@50 $@70 $@90 $@
c) 30 $@40 $@70 $@90 $@ d) 40 $@50 $@

11 Which of the following is not a valid URL: 1. kvsangathan.nic.in 2. www.google.com


1
3. acad@google.com 4. http://cbseacademic.nic.in/curriculum_2022.html
a)1 & 3 b) 3 & 4 c) Only 3 d)Only 4

12 Complete the missing line of code in #statement 1 to produce the output as 50 : 1


x=100
def study(x):
________________ # statement 1
x=50
print(“Value of x is :”, x)
Look at the code below and identify the type of exception that will be thrown from the options
13 arr=[10,20,30,40,50,60,70,80,90,100]
for i in range(len(arr)+1):
print(arr.pop())
1
14 Identify the False relational database statement from the options below.
a) Alternate key(s) are the Candidate key(s) not selected as Primary key.
1
b) Foreign key of a table is a Primary key of the table it points to.
c) There can be many Candidate keys in a table.
d) Referential Integrity is enforced by the Alternate keys.

15 Suryansh wants to upload and download files from / to a remote internal server. 1
Write the name of the relevant communication protocol, which will let him do the same.
16 Consider the code:
lines = ['This is line 1', 'This is line 2'] 1
with open('readme.txt', 'w') as f:
for line in lines:
f.write(line+’\n’)
Which of the following statements is true regarding the content of the file ‘readme.txt’?
a) Both strings of list lines will be written in two different lines in the file ‘readme.txt’.
b) Both strings of list lines will be written in the same line in the file ‘readme.txt’.
c) string 1 of list lines will overwrite string 2 of list lines in the file ‘readme.txt’.
d) string 2 of list lines will overwrite string 1 of list lines in the file ‘readme.txt’.

Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as:
a) Both A and R are true and R is the correct explanation of A
b) Both A and R are true and R is not the correct explanation of A
c) A is True but R is False
d) A is false but R is True

17 Assertion (A): Variables whose values can be changed after they are created and assigned are
called immutable. 1
Reason ( R ): When an attempt is made to update the value of an immutable variable, the old
variable is destroyed and a new variable is created by the same name in memory.

18 Assertion (A): The function definition calculate(a, b, c=1,d) will give error.
1
Reason (R): All the non-default arguments must precede the default arguments.

SECTION B

19 The following code that consists of a function and user input part is supposed to return the 2
factors of a number supplied as a parameter. Since there are errors in both syntax and logical
errors it’s not showing the correct result. Your task is to identify and underline the errors.

def problem(n):
myList = ( )
for i in range(1, n+1):
if n // i =0:
myList.append(i)
return myLis
problem(4):

20 i) Expand the following: FTP & POP


ii) Write the difference between web server and web browser. 2
OR
i) How Hub is different from switch.
ii) Explain the 80-20 rule of network design?
21 Consider the string G20 below G20="African Union has been included as a member of the
G20". Write a function lenWords(G20) that takes the string as its parameter and returns the 2
length of each word of the string as a tuple.

OR
CBG is a dictionary that stores the name of the country and their respective Central Banks
Governor’s name as shown below.
CBG={"Germany":"JoachimNagel","France":"FrancoisVilleroy de Galhau",
"India":"ShaktikantaDas", "UnitedKingdom":"AndrewBailey",
"UnitedStates":"Jer ome Powell"}
Write a function getNames(CBG) that will take the dictionary as its parameter and will display
only those Governor’s names which are more than 20 characters long including the spaces in
between.

22 Find the output of the following code:


box={} 2
jars={}
crates={}
box['biscuit']=3
box['cake']=4
print (box)
jars['jam']=4
print (jars)
crates['box']=box
crates['jars']=jars
print(crates)

23 Write the Python statement for each of the following tasks using built-in functions / methods
only: 2
i) To add another alphabet ‘e’ after the alphabet ‘e’ in the list
L=["C","a","r","e","r","F","a","i","r"]
ii) Check if the string S="eComPhyMat" starts with the alphabet ‘e’.
OR
Determine the most frequent alphabet in the list L=["C","a","r","e","e","r","F","a","i","r"] by
importing appropriate module in Python

24 i) Mr. Akshat has added a not null constraint to the “name” field in the “employees” table. But
now he wants to remove that not null constraint. Write the command to delete the not null 2
constraint from name feld.
ii) While creating a table 'Customer' Simrita forgot to set the primary key for the table. Give
the statement which she should write now to set the column 'CustiD' as the primary key of the
table?
OR
i) While creating the table Student last week, Ms. Sharma forgot to include the column
Game_Played. Now write a command to insert the Game_Played column with VARCHAR
data type and 30 size into the Student table?
ii) Kunal created the following table with the name ‘Friends’ containing the attributes -
Friendcode, Name & Hobbies. Now, Kunal wants to delete the ‘Hobbies’ column. Write the
MySQL statement for the same.

25 Find the output of the following: 2


def anher(x,y=10):
x=x/y
y=x%y
return x
m=200
n=20
m=anher(m,n)
print(m,n,sep="#")
n=anher(n)
print(m,n,sep="#",end="$$$")

SECTION C

26 Predict the output of the following Python code given below:


s="welcome2kv" 3
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)

27 Write the output of the queries (i) to (iii) based on the table, TEACHER given below:
TEACHER 3

TCODE TNAME SUBJECT SEX SALARY

5467 Narendra Kumar Computer Science M 70000

6754 Jay Prakash Accountancy M Null

8976 Ajay Kumar Chemistry M 65000

5674 Jhuma Nath English F 55000

8756 Divya Bothra Computer Science F 75000

6574 Priyam Kundu Physics M Null

3425 Dinesh Verma Economics M 71000


i) SELECT SUBJECT , COUNT(*) AS TOT_FACUL FROM TEACHER GROUP BY
SUBJECT HAVING TOT_FACUL > 1;
ii) SELECT TNAME FROM TEACHER WHERE SEX = ‘M’ AND SALARY >= 70000
ORDER BY TCODE;
iii) SELECT MAX(SALARY) FROM TEACHER WHERE TCODE IN (5467,8976,3425)
AND SUBJECT LIKE ‘C%’ ;

28 Write a function COUNTLINES( ) which reads a text file STORY.TXT and then counts and
displays the number of the lines which starts and ends with the same letter irrespective of its 3
case.
For example, if the content of the text file STORY.TXT is :
The person has a sent a lovely tweet
Boy standing at station is very disturbed
Even when there is no light we can see
How lovely is the situation
The expected output is : The Number of lines starting with the same letter is 2.
OR
Write a function countwords() in Python that counts the number of words containing digits in
it present in a text file “myfile.txt”.
Example: If the contents are as follows:
This is my 1st class on Computer Science. There are 100 years in a Century. Student1 is
present in the front of the line.
The output of the function should be: 3

29 Consider the table carmaster. 3

Field Type Null Key Default Extra

company varchar(30) NO PRI

model varchar(30) YES NULL

rateperhour int(11) YES NULL


i) Write the SQL command to add a field noofgears, int type after the attribute model.
ii) Write the command to update the field noofgears to 6 for all the records of the table
carmaster.
iii) Write the command to drop the field noofgears.

30 A list items contain the following record as list elements [itemno, itemname, stock]. Each of 3
these records are nested to form a nested list. Write the following user defined functions to
perform the following on a stack reorder
i) Push(items): It takes the nested list as its argument and pushes a list object containing
itemno and itemname where stock is less than 10.
ii) Popitems(): It pops the objects one by one from the stack reorder and also displays a .
message ‘Stack empty’ at the end.

SECTION D
31 Consider the following table RECIPIENT and SENDER. Write SQL commands fro the 4
following statements:
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 Prasad 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 East Mumbai

MU32 MU15 P K Swamy B5, C S Terminus Mumbai

ND48 ND50 S Tripathi 13, B1 D, Mayur Vihar New Delhi

i) Display the structure of the table RECIPIENT.


ii) To display the RecId, SenderName, SenderAddress, RecName, RecAddress for every
recipient.
iii) To display recipient details in ascending order of RecName.
iv) To display the number of recipients from each city.

32 Radha Shah is a programmer, who has recently been given a task to write a python code to 4
perform the following CSV file operations with the help of two user defined functions/modules:
a) CSVOpen() : to create a CSV file called “ books.csv” containing information about books
of 5 records – [Title, Author and Price] with the headings.
b) CSVRead() : to display the records from the CSV file called “ books.csv” .where the field
title starts with 'R'.

SECTION E

33 Perfect Edu Services Ltd. is an educational organization. It is planning to setup its India 5
campus at Chennai with its head office at Delhi. The Chennai campus has 4 main buildings –
ADMIN, ENGINEERING, BUSINESS and MEDIA.
You as a network expert have to suggest the best network related solutions for their problems
raised in (i) to (v), keeping in mind the distances between the buildings and other given
parameters.
Shortest distance between various buildings:
Admin to Engineering 55 m

Admin to Business 90 m

Admin to Media 50 m

Engineering to Business 55 m

Engineering to Media 50 m

Business to Media 45 m

Delhi Head Office to Chennai Campus 2175 KM

Number of computers installed at various buildings are as follows:


Admin 110

Engineering 75

Media 12

Business 40

Delhi Head Office 20

i) Suggest the most appropriate location of the server inside the CHENNAI campus (out of the
4 buildings), to get the best connectivity for maximum no. of computers. Justify your answer.
ii) Suggest and draw the cable layout to efficiently connect various buildings within the
CHENNAI campus for connecting the computers.
iii) Which hardware device will you suggest to be procured by the company to be installed to
protect and control the internet use within the campus ?
iv) Which of the following will you suggest to establish online face-to-face communication
between the people in the Admin Office of CHENNAI campus and DELHI Head Office ?
a) Cable TV b) Email c) Video Conferencing d) Text Chat
v) Name protocols used to send and receive emails between CHENNAI and DELHI offices.
34 i) Write the importance of flush( ). 1+4=5
ii) Alia has been given a task of writing a code to create a binary file EMPLOYEE.DAT with
employeeid, ename and salary. The file contains 10 records. He now has to update a record
based on the employee id entered by the user and update the salary. The updated record is
to be written in the file updateemp.dat. The records which are not to be updated also have to
be written to the file updateemp.dat. If the employee id is not found, an appropriate message
should be displayed. Write a user defined function update_data( ) to complete the above task.
OR
i) Explain the process of serialization in the Binary file.
ii)A binary file Book.dat has a structure [bookno,book_name,author,price].Write a function in
Python count_book() to count and return the no.of books whose price is between 100 and 500.

35 i) Are count (*) and count()the same functions? Why/why not? 1+4=5
ii) The code given below inserts the following record in the table Emp:
EmpNo – integer
EName – string
Desig – string
Salary – integer

Note the following to establish connectivity between Python and MYSQL:


Username is admin
Password is 22admin66
The table exists in a MYSQL database named company.
The details (EmpNo, EName, Desig and Salary) are to be accepted from the user. Write the
program in Python to meet the above need.
OR

i) Give one point of difference between an equi-join and a natural join.


ii) Write the user defined function display ( ) in python to execute the query that fetches
records of the employees coming from the city ‘Delhi’.
E_code - string
E_name - String
Sal = Integer
City - string
Note the following to establish connectivity between Python and MySQL:
❖ Username is root
❖ Password is root
❖ The table exists in a MySQL database named emp.
❖ The details (E_code, E_name, Sal, City) are the attributes of the table.
Sample Paper 24
Computer Science (083)
CLASS XII 2023-24

Maximum Marks: 70 Time Allowed: 3 hours

SECTION-A
1. Name the Python library module needed to be imported to invoke 1
following functions:
a. floor ( )
b. randomint ( )

2. To use function of any module, we have to use ____________ (command) 1


before the use 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 1
group the 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

1
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 1
“Students.txt” 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’)

12. Fill in the blank: 1


The ………………. clause, places condition with aggregate functions .

(a) HAVING
(b) WHERE
(c) IN
(d) BETWEEN

13. Write the full forms of: 1


a. PPP
b. VOIP
14. Find the output: 1
tuple1 = (10,12,14,16,18,20,22,24,30)
print( tuple1[5:7] )

15. Which of the following is not an aggregate function? 1


(a) AVG
(b) MAX
(c) JOIN
(d) COUNT
16. Name the module used to establish a database connection with a python 1
program.
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 1
pseudo-random variables.
Reason(R): The randrange() function is used to generate a random number
between the specified range in its parameter.
2
SECTION-B
19. Yuvika has to complete her computer science assignment of demonstrating 2
the use of if-else 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 1
expressions:
a) k= 7 + 3 **2 * 5 // 8 – 3
print(k)
b) m= (8>9 and 12>3 or not 6>8) 1
print(m)
22. What do you understand by table constraint in a table? Give a suitable 2
example in support 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

Find the output:

def func(n1 = 1, n2= 2):


n1= n1 * n2
n2= n2 + 2
print(n1, n2)

func( )
func( 2,3)
OR

Predict the output of the Python code given below:

T= [“20”, “50”, “30”, “40”]


Counter=3
Total= 0
for I in [7,5,4,6]:
newT=T[Counter]
Total= float (newT) + I
print(Total)
Counter=Counter-1
3
25. Rohit wants to increase the size of the column FeeAmount by 5, which is 2
possible category out of DML / DDL of command he has to use to:
(Write DDL or DML alongwith command / query)
Display the structure of table (DDL or DML)
Increase the size of column FeeAmount by 5 (DDL or DML)
OR
Differentiate between char(n) and varchar(n) data types with respect to
databases.

SECTION C

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=2;
(iii) Select AVG(STIPEND) from STUDENT where AVERAGE>=65;
(iv) Select COUNT(distinct SUBJECT) from STUDENT;

4
27. Write a definition of a function calculate () which count the 3
number of digits in a file “ABC.txt”.
OR
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 3
tablesEmp:

EmpCode Ename Salary JoinDate


E001 Raman 55000 2019-10-11
E002 Neha 65000 2019-11-20
E003 Priya 60000 2020-01-28
E004 Raghav 58000 2020-02-16
(i) Select ename, salary from emp where name like ‘_r%’
(ii) Select count(salary) from emp where joindate>’2019-11-28’
(iii) Select max(joindate), min(joindate) from emp

(b) Write the command to list all the databases in MySQL.


29. 11. Write definition of a Method MSEARCH(STATES) to display all the 3
state names from a list ofSTATES, 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 3
element to be 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

5
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.
Distance Between Blocks No. of Computers
Block A to Block B 50m Block A 25
Block B to Block C 150m Block B 50
Block C to Block D 25m Block C 125
Block A to Block D 170m Block D 10
Block B to Block D 125m
Block A to Block C 90m
1
(i) Suggest a cable layout of connection between the blocks (Diagram).
1
(ii) Suggest the most suitable block to host the server along with the reason.
(iii) Where would you place Repeater devices? Answer with justification. 1
(iv) The organization is planning to link its front office situated in the city
in a hilly region where cable connection is not feasible, suggest 1
an economic way to connect it with reasonably high speed. 1
(v) Where would you place Hub/Switch? Answer with justification.
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. ()

query=”select * from stmaster”


cur.execute( )
resultset=cur.fetchmany(3)
for row in resultset:
print(row)
dbcon.________()
6
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 5
user id and 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()

with open('d:\\a.csv','r') as newFile:


newFileReader = csv. (newFile) #Line 3
for row in newFileReader:
print (row) #Line 4
newFile. #Line 5

a) Name the module he should import in Line 1


b) Fill in the blank in line 2 to write the row.
c) Fill in the blank in line 3 to read the data from csv file.
d) Write the output while line 4 is executed.
e) Fill in the blank in line 5 to close the file.
OR
ANSHU is writing a program to search a name in a CSV file
7
“MYFILE.csv”. He has written thefollowing code. As a programmer, help
him to successfully execute the given task.
import # Statement 1
f = open("MYFILE.csv", ) # Statement 2
data = ( f ) # Statement 3
nm = input("Enter name to be searched: ")
for rec in data:
if rec[0] == nm:
print (rec)
f. ( ) # Statement 4

(a) Name the module he should import in Statement 1.


(b) In which mode, MOHIT should open the file to search the data in
the file in statement 2?
(c) Fill in the blank in Statement 3 to read the data from the file.
(d) Fill in the blank in Statement 4 to close the file.
(e) Write the full form of CSV.
SECTION-E
34. Dinesh creates a table COMPANY with a set of 06 records. 1+1+2

C_ID F_ID Cname Fees


C21 102 Grid Computing 40000
C22 106 System Design 16000
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000

Based on the data given above answer the following questions:

(a)Identify the most appropriate column, which can be considered as


Primary key.
(b) If 3 columns are added and 2 rows are deleted from the table result,
what will be the new degree and cardinality of the above table?
(c) Write the statements to:
(i) delete a record which has C_ID as C24
(ii) Increase the Fee of all by 500.

OR (Option for part (C) only)

(i) Add a column PLACE in the table with datatype as varchar with
20 characters.
(ii) Query to display all the records.

8
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 (a) & (b):

(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).

9
Sample Paper 25
Computer Science (083)
CLASS XII 2023-24
Maximum Marks: 70 Time Allowed: 3 hours
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is
given in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1. State True or False 1
“Name of Variable come always after the assignment operator in python.
2. Which of the following is valid datatype in Python? 1
(a) tuple (b) None (c) float (d)All the options
3. Give the output: 1
dic1={‘r’:’red’,’g’:’green’,’b’:’blue’}
for i in dic1:
print (i,end=’’)
a. rgb
b. RGB
c. RBG
d. rbg
4. Consider the given expression: 1
not True 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
a = "Year 3033 at All the best"
a = a.split('3')
b = a[0] + ". " + a[1] + ". " + a[2]
print (b)
(a) Year . 0. at All the best
(b) Year 0. at All the best
(c) Year . 0.
(d) Year . 0. all the best

1
6. Which of the following mode, file should be open if we want to add new 1
contents in in existing file contents?
(a) a (b) r (c) w (d) None of the above
7. Fill in the blank: 1
command is used to remove the tuple from the table in SQL.
(a) update (b)remove (c) alter (d) delete
8. Which of the following commands will show the structure of table from 1
MYSQL database?
(a) SHOW TABLES
(b) DISPLAY TABLES
(c) DESCRIBE TABLE-NAME
(d) ALTER TABLE
9. Which of the following statement(s) would give an error after 1
executing the following code?
S="Welcome to KVS" # Statement 1
print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '$' # Statement 4
S=S+"Thank you" # Statement 5
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
10. Fill in the blank: 1
is a non-key attribute, which gives referential integrity
concept in two tables.
(a) Primary Key
(b) Foreign Key
(c) Candidate Key
(d) Alternate Key
11 Which method is used to move the file pointer to a specified position.
(a) tell()
(b) seek()
(c) seekg()
(d) tellg()
12 Fill in the blank:
The SELECT statement when combined with clause,
returns records with repetition.
(a) DESCRIBE
(b) ALL
(c) DISTINCT
(d) NULL
13 Fill in the blank:
is a communication methodology designed to deliver emails over
Internet protocol.
(a) VoIP (b) SMTP (c) PPP (d)HTTP

2
14. What will the following expression be evaluated to in Python? 1
print(15.0 // 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5

15. Which one of the following function is an invalid multiple row function? 1
(a) sum()
(b) total()
(c) count(*)
(d) avg()
16. Which function should be used to display the number of records as per need 1
of a user during interface with python and SQL database.
(a) fetchone()
(b) fetchmany()
(c) fetchall()
(d) fetchshow()
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct
choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17. Assertion (A): A function is block of organized and reusable code that is 1
used to perform a single, related action.
Reasoning (R):- Function provides better modularity for your application and
a high degree of code reusability.
18. Assertion (A): Access mode ‘a’ opens a file for appending. 1
Reason (R): The file pointer is at the end of the file if the file exists.
SECTION-B

19 Harsh has written a code to input a number and find a table of any
number.His code is having errors. Rewrite the correct code and
underline the corrections made.
def table():
n=int(("Enter number which table U need: ")
for i in (1,11):
print("Table of Enter no=”,i*i)
Table()
20 Identify the switching technique according to the given statement.
(i) A methodology of implementing a telecommunication network in
which two network nodes establish a dedicated communication
channel.
(ii) the message gets broken into small data packets and Store and
forward technique used.
OR
What is web browser? Give any two examples of it which you used in your
life.
21. (a) Given is a Python string declaration: 1
myexam="##CBSE Examination 2023@@"
Write the output of: print(myexam[::-3])
3
(b) Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26} 1
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.values())
22 Explain the use of ‘Primary Key’ in a Relational Database Management
System. Give example to support your answer.
23. (a) Write the full forms of the following: 2
(i) VoIP (ii) TCP/IP

(b) If we want to access remote computer than which command should be


used in networking?
24. Predict the output of the Python code given below: 2

def Diff(N1,N2):
if N1<N2:
return N1-N2
else:
return N2*N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')
OR
Predict the output of the Python code given below:
tuple1 = (1, 11, 22, 33, 44 ,55)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%3==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)

4
25. Differentiate between count() and count(*) functions in SQL with 2
appropriate example.
OR
Categorize the following commands as DDL or DML:INSERT, ALTER, DROP,
DELETE,UPDATE,CREATE
26 (a) Consider the following tables – LOAN_Account and Branch:
Table: Bank_Account
ACode Name Type
A01 Amrita Savings
A02 Parthodas Current
A03 Miraben Current
Table: Branch
ACode City
A01 Delhi
A02 Mumbai

What will be the output of the following statement?


SELECT * FROM LOAN_Account JOIN Branch;
(b) Write the output of the queries (i) to (iv) based on the table,COURSE
given below:
Table: COURSE

CID CNAME FEES STARTDATE TID


C201 Animation 12000 2022-07-02 101
and VFX
C202 CADD 15000 2021-11-15 NULL
C203 DCA 10000 2020-10-01 102
C204 DDTP 9000 2021-09-15 104
C205 Mobile 18000 2022-11-01 101
Application
C206 Digital 16000 2022-07-25 103
marketing

(i) SELECT ALL TID FROM COURSE;


(ii) SELECT TID, COUNT(), MAX(FEES) FROM COURSE
GROUP BY TID HAVING COUNT(TID)>1;
(iii) SELECT CNAME FROM COURSE WHERE
FEES>15000 ORDER BY CNAME DESC;
(iv) SELECT SUM(FEES) FROM COURSE WHERE
FEES BETWEEN 15000 AND 17000;
27. Write a method COUNTWORDS() in Python to read words from text file 3
‘TEST.TXT’ and display the words which are not starting with d.
Example:
If the file content is as follows:

An apple a day keeps the doctor away.


We all pray for everyone’s safety.
A marked difference will come in our country.
The COUNTWORDS() function should display the output as:
The number of words not starting with d:-19
5
OR
Write a function Count() in Python, which should read those lines which
start with ‘I’ or ‘i’ of a text file “TEST.TXT” and then count and display the
no of liens which start with ‘I’ or ‘i’ (including small cases I and i too).
Example:
If the file content is as follows:
Today is a pleasant day.It
might rain today.
it is mentioned on weather sites

The Count() function should display the output as:


It might rain today.
it is mentioned on weather sites
I or i: 2

28
Write SQL commands for (i) to (vi) on the basis of table STUDENT:
Table : STUDENT
ADMNO NAME STREAM FEES AGE SEX
1 RAEESH SCIENCE 3000 15 MALE
2 SATISH ARTS 2000 14 MALE
3 SUMAN SCIENCE 4000 14 FEMALE
4 SURYA COMMERCE 2500 13 FEMALE
5 SURESH ARTS 2000 13 MALE
(i) List the name of all the students, who have taken stream as
science.
(ii) To count the number of female students.
(iii) To display the number of students, stream wise.
(iv) To display all the records in sorted order of name.
(v) To display the stream of student whose name start from ‘s’.
(vi) To display the name and fees of students whose fees range from
3000 to 4000(both values of fees included)
29 Write a function LShift(Arr,n) in python, which accepts a list Arr of numbers
and n is a numeric value by which all elements of the list are shifted to left.
Sample Input Data of the list.
Arr=[10,20,30,40,12,11], n=2 Output Arr=[30,40,12,11,10,20]

30 ICCI has created a dictionary containing top players and their runs as key
value pairs of cricket team. Write a program, with separate user defined
functions to perform the following operations:
Push the keys (name of the players) of the dictionary into a stack, where
the corresponding value (runs) is greater than 50.Pop and display the
content of the stack.
For example:
If the sample content of the dictionary is as follows:
SCORE={"KAPIL":40, "SACHIN":55, "SAURAV":80, "RAHUL":35,
"YUVRAJ":110, }
The output from the program should be: SACHIN SAURAV YUVRAJ

6
OR
Vikram has a list containing 10 integers. You need to help him create a
program with separate user defined functions to perform the following
operations based on this list. Traverse the content of the list and push
the ODD numbers into a stack. Pop and display the content of the stack.
For Example:
If the sample Content of the list is as follows:
N=[14, 15, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be: 15,21,79,35
Section- D
31 StartIndia Corporation, an Jharkhand based IT training company, is
planning to set up training centers in various cities in next 2 years. Their
first campus is coming up in Ranchi district. At Ranchi campus, they are
planning to have 3 different blocks for App development, Web designing
and Movie editing. Each block has number of computers, which are
required to be connected in a network for communication, data and
resource sharing. As a network consultant of this company, you have to
suggest the best network related solutions for them for issues/problems
raised in question nos.
(i) to (v), keeping in mind the distances between various blocks/locations
and other given parameters.

Distance between various blocks/locations:

Block Distance
App development to Web designing 38 m
App development to Movie editing 105 m
Web designing to Movie editing 42 m
Ranchi Campus to Gumla Campus 232 km

Number of computers
Block Number of Computers
App development 65
Web designing 40
Movie editing 70

(i) Suggest the most appropriate block/location to house the SERVER in


the Ranchi campus (out of the 3 blocks) to get thebest and effective
connectivity. Justify your answer.
7
(ii) Suggest a device/software to be installed in the RanchiCampus to take
care of data security.
(iii) Suggest the best wired medium and draw the cable layout
(Block to Block) to economically connect various blocks within
the Ranchi Campus.
(iv) Suggest the placement of the following devices with
appropriate reasons:
a. Switch / Hub
b. Repeater
(v) Suggest a protocol that shall be needed to provide Video Conferencing
solution between Ranchi Campus and Gumla Campus.

32 (a) Write the output of the code given below:


p=7
def add(q,r=3):
global p
p=r+q**2
print(p, end= '#')
a=10
b=5
add(a,b)
add(r=5,q=1)
(b) The code given below inserts the following record in the table
Student:
RollNo – integer
Name – string
Clas – integer
Marks – 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 school.
 The details (RollNo, Name, Clas and Marks) are tobe
accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the connection
Statement 2-to form the cursor object
Statement 3 – to execute the command that inserts the record in thetable
Student.
import mysql.connector as mysql
def sql_data():
con1=…………………__(host="localhost",user="root", password="tiger",
database="school") #Statement 1
mycursor=…………………………. #Statement 2
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 3
print("Data Added successfully")
8
OR
(a) Predict the output of the code given below:

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 tablenamed
student and displays only those records who have marks greater than
or equal to 90:
RollNo – integer
Name – string
Clas – integer
Marks – 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 school.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those
students whose marks are less than or equal to 90.
Statement 3- to read the complete result of the query (records whose
marks are less than or equal to 90) into the object named data, from
the table studentin the database.

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="school")
mycursor= #Statement 1
print("Students with marks less than or equal to 90 are :")
………………. #Statement 2
data= #Statement 3
for i in data:
print(i)

9
33 Abhisar is making a software on “Countries & their Capitals” in which
Various records are to be stored/retrieved in CAPITAL.CSV data file. It
consists some records(Country & Capital). He has written the following
code in python. As a programmer, you have to help him to successfully
execute the program.

import # Statement-1

def AddNewRec(Country,Capital): # Fn. to add a new record in CSV file


f=open(“CAPITAL.CSV”, ……) # Statement-2
fwriter=csv.writer(f)
fwriter.writerow([Country,Capital])
f. # Statement-3
def ShowRec(): # Fn. to display all records from CSV file
with open(“CAPITAL.CSV”,”r”) as NF:
NewReader=csv. (NF)# Statement-4
for rec in NewReader:
print(rec[0],rec[1])
AddNewRec(“INDIA”,”NEW DELHI”)
AddNewRec(“CHINA”,”BEIJING”)
ShowRec() # Statement-5
(a) Name the module to be imported in Statement-1.
(b) Write the file mode to be passed to add new record in Statement-2.
(c) Fill in the blank in Statement-3 to close the file.
(d) Fill in the blank in Statement-4 to read the data from a csv file.
(e) Write the output which will come after executing Statement-5.
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) add() – To accept and add data of an employee to a CSV file


‘empdata.csv’. Each record consists of a list with field
elements as eid, ename and esalaryto store emp id, emp
name and esalary respectively.
(ii) search()- To display the records of the emp whose
salary is less than 70000.

SECTION-E

10
34 Pardeep creates a table STORE with a set of records to maintain the
Watch details. After creation of the table, he has entered data of 5 watch
information in the table.

Watchid Watch_Na Price Type Qty Brand


me
W001 High Time 10000 Unisex 100 Titan

W002 Life Time 15000 Ladies 150 John


player
W003 Wave 20000 Gents 200 Citizen
W004 High 7000 Unisex 250 Sony
Fashin
W005 Golden 25000 Gents 100 Rado
Time

Based on the data given above answer the following questions:


(i) Identify the most appropriate column, which can be considered
As Primary key.
(ii) If two columns are deleted and 2 rows added from the table store
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
Watchid-W006, Watchname-Prime Time,Price-12000,Type-
Ladies,Qty-120, Company-Samsung
(b) Increase the price by 5000 of those watch whose brand is rado.
OR(Option for part iii only)
(a) Delete the record of watches whose Type as Unisex.
(b) To add an column Wdiam in table store with datatype as int.

35 (i) Why we need a binary file?


(ii)A binary file named “TEST.dat” has some records of the structure
[TestId, Subject, MaxMarks, ScoredMarks]
Write a function in Python named Display AvgMarks(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.

11
Sample Paper 26
Computer Science (083)
CLASS XII 2023-24

Maximum marks: - 70 Time: - 3 Hr


General Instructions: -
 This question paper contains 5 sections. Section A to E
 All questions are compulsory
 Section A has 18 questions of 1 mark each.
 Section B has 7 questions very short answer type of 2 marks each
 Section C has 5 questions short answer type of 2 marks each
 Section D has 3 questions long answer type of 2 marks each
 Section E has 2 questions of 4 marks each. One internal choice is given in Q35
against part C only
 All programming questions are based on Python Programming language.
SECTION A
Q.1 State Ture of False 1
True is not False in [True, False]
Q.2 Which is unordered sequence 1
(a) tuple (b) list (c) dictionary (d) String
Q.3 What will be the content of dictionary d after executing the following 1
code
d={1:100,2:200}
t=(1,2,3)
d.fromkeys(t)
Q.4 What will be the output of the following code 1
3>2>1*5
(a) Ture (b) False (c) Error (d) None of all
Q.5 Predict the result of the following code 1
“@”.join(“abc-gmail.com”.split(“-“)
Q.6 Which open method of file handling does not require file to be close 1
explicitly.
Q.7 Which pair of SQL Statement is not from the same category of SQL 1
command
(a) create, alter
(b) insert, delete
(c) delete, drop
(d) update, delete
Q.8 Choose valid statement 1
(a) insert command is part of DDL
(b) insert command insert a row at beginning
(c) insert command can insert a row any where
(d) insert command insert many rows
Q.9 Mr khan has written following python code. Choose the one which will 1
not execute
(a) t=(10,20)+(30,40)
(b) t=(10,20)+(30)
(c) t=10+(10)
(d) t=(10,20)+(30,)
Q.10 A key of a table is not primary key but can be selected as primary key. 1
Choose the correct answer for the above given statement
(a) Secondary key (b) Alter table
(c) Candidate key (d) Foreign key
Q.11 Correct syntax to open a binary file in read mode is 1
(a) F=open(“abc.dat”,”b”,”r”)
(b) F=open(“abc.dat”,”br”)
(c) F=open(“abc.dat”,”rb”)
(d) F=open(“abc.dat”,”r”,”b”)
Q.12 The correct definition of column ‘alias’ is 1
(a) A permanent new name of column
(b) A new column of a table
(c) A view of existing column with different name
(d) A column which is recently deleted
Q.13 Fill in the blank 1
The service for remote login is called ____________
(a) Telnet
(b) Web browser
(c) Firewall
(d) Cookies
Q.14 Correct statement for ab is 1
(a) math.pow(a,b)
(b) a**b
(c) both a and b are correct
(d) math.sqrt(a,b)
Q.15 To view the list of tables of a database, the correct command is ____ 1
(a) list tables
(b) show tables
(c) display tables
(d) view tables
Q.16 Using python mysql connectivity the correct code to display all the 1
available databases of Mysql with the help of a cursor mcur is
(a) mcur.execute(“show database”)
(b) mcur.execute(“desc database”)
(c) mcur.execute(“show databases”)
(d) mcur.execute(“desc databases”)
Question 17 and 18 are ASSERTION AND REASONING based. Mark the
correct choice as
(a) A and R are True and R is correct explanation of A
(b) A and R are True and R is not correct explanation of A
(c) A is True but R is False
(d) A is False but R is True
Q.17 Assertion(A): if an existing file whose size was 50 Byte is opened in 1
write mode and after writing another 50 Byte into file it is closed. The
file size is 100 Byte after closing.
Reason(R) : File size will remain 50 Byte as it was not opened in
append mode so old content will be lost.
Q.18 Assertion(A): A function can take no argument or any number of 1
argument and writing of return keyword is not compulsory
Reason(R) : If we do not write return key word the function will return
None value.
SECTION B
Q.19 The following code has some error. Rewrite the code underling the 2
correction made.
def funpara(a=20,b=10,c)
if a>b:
print(“first is big”)
else:
print(“second is big”)
Return(“Third number is missing”)
Q.20 Write one advantage and one disadvantage of circuit switching 2
OR
Which language is the most suitable language to create static web pages?
Does your suggested language has pre defined tags.
Q.21 Write correct code to produce output “retupmoc” if a variable s1 1
contains “computer”
(a) s1=”computer”
print(s1[_______])

1
(b) Write the correct output of following code
d={1:100,2:200}
for x,y in d:
print(x,d[x],end=’’)
Q.22 How many candidate key and primary key a table can have? Can we 2
declared combination of fields as a primary key?
Q.23 (a) Which protocol is used to upload files on web server? 2
(b) Expand the term TCP/IP
Q.24 Choose the best option for the possible output of the following code 2
import random
L1=[random.randint(0,10) for x in range(3)]
print(L1)
(a) [0,0,7] (b) [9,1,7] (c) [10,10,10] (d) All are possible

OR
import random
num1=int(random.random()+0.5)
What will be the minimum and maximum possible values of variable
num1
Q.25 Mrs sunita wrote a query in SQL for student table but she is not getting 2
desired result
select * from student where fee = NULL;
Rewrite the above query so she well gets desired result
OR
What is the difference between delete and drop command?
SECTION C
Q.26 (a) What is the difference between not-equi join and equi join. 1+2
(b) Consider the TEACHER table given below
TEACHER SUBJECT GENDER AGE
MANOJ SCIENCE MALE 38
NIKUNJ MATHS MALE 40
TARA SOCIAL FEMALE 38
SCIENCE
SUJAL SCIENCE MALE 45
RAJNI SCIENCE FEMALE 52
GEETA HINDI FEMALE 31
Write OUTPUT of the following queries
(a) select count(distinct subject) from teacher;
(b) select count(*) from teacher group by gender;
(c) select sum(age) from teacher where age >40 group by gender;
(d) select count(*) from teacher group by subject having count(*)>1;
Q.27 Write a function readstar() that reads a text file STORY.TXT and display 3
line numbers that contains * anywhere. For example, the file contains
The multiplication symbol * has many meaning
The * can also be used as pointer
The addition symbol + also has many meaning
The output of the readstar() should be
Line no 1 has star
Line no 2 has star
OR
Write a function word5count() that count number of words whose
length is more than 5 characters in above given STORY.TXT file.
Q.28 (a) Consider the doctor and patient table and write the output of (i) to 3
(iv)
Doctor
docid Dname Specialization Outdoor
D1 MANISH PHYSICIAN MONDAY
D2 PARESH EYE FRIDAY
D3 KUMAR ENT SATURDAY
D4 AKASH ENT TUESDAY

Patient
Pid Pname did Date_visit
P1 Lal singh D2 2022-04-25
P2 Arjun D1 2022-05-05
P3 Narender D4 2022-03-13
P4 Mehul D3 2022-07-20
P5 Naveen D2 2022-05-18
P6 Amit D1 2022-01-22

(I) select count(*) from patient where date_visit like ‘%2_’;


(II) select count(*) from doctor group by specialization;
(III) select a.dname, b.pname from doctor a, patient b where
a.docid=b.did;
(IV) select dname from doctor,patient where docid=did and
pname=’Arjun’;

(c) With reference to RDBMS define attribute.

Q.29 Write a function exchange() that accept two list as parameter. The two 3
list contains integer values. The function should return a single list that
stores all the values of both list in sorted form. For example
L1=[4,20,9,15]
L2= [7,0,70]
The returned list should be [0,4,7,9,15,20,70]
Q.30 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]

After Push_na() the contains of Lnameage stack is


[(‘raju’,59),(‘amit’,51)]
The output of first execution of pop_na() is
The name removed is amit
The age of person is 51
OR
A dictionary stu contains rollno and marks of students. Two empty list
stack_roll and stack_mark will be used as stack. Two function push_stu()
and pop_stu() is defined and perfom following operation
(a) Push_stu() :- It reads dictionary stu and add keys into stack_roll
and values into stack_marks for all students who secured more
than 60 marks.
(b) Pop_stu() :- it removes last rollno and marks from both list and
print “underflow” if there is nothing to remove
For example
stu={1:56,2:45,3:78,4:65,5:35,6:90}

values of stack_roll and stack_mark after push_stu()


[3,4,6] and {78,65,90}
SECTION D
Q.31 The BPL corporation has 4 offices(Admin office, account office, marketing
office and training office) situated at different locations of a metro city.
Company is planning to connect all its offices through network. It wants
to control all the office from admin office and all kind of work done in its
office has been computerized. Now it wants to establish network among
all its offices. Distance between its offices and number of computers in
each office is given. You have to suggest best option for the following
issues.

Distance between each offices No of computers in


each offices
Admin to account 40 km Admin 120
Admin to 20 km Account 20
marketing
Admin to training 25 km Training 50
Training to account 70 km marketing 30 1
Training to 65 km
marketing 1
Marketing to 55 km
account 1

(i) Which device should be used in each office to connect each 1


computer of the office 1
(ii) To protect all incoming and outgoing data from hackers which
hardware or software should be used.
(iii) You are to suggest a plan to protect all individual computers
from Phishing web sites, virus, trojan and worm attack.
(iv) Suggest the best cable layout to connect all the computers of
the company
(v) Suggest where SERVER should be installed.
Q.32 (a) Predict the output of the following code 2+3
email=”Way2sma@gmail.com”
for x in email.split(“@”):
if ‘a’ in x:
print(x[0:3]
if x in “.”:
print(x[0:5])
(b)
A mysql table class contains following columns
-Roll no
-Name
-Marks
The mysql database has following details
User =‘python’
Password=’test’
database=student

The code given below calculate the sum of marks of all student. Fill in
the blanks

import mysql.connector
con=_____________________.connect(host=’localhost’, user=’python’,
password=’test’, database=’student’) # statement 1
cur1=con.cursor()
cur1.____________(“select * from class”) # statement 2
total=0
for x in __________: # statement 3
total=total+int(x[2])
print(“total marks of all students :- “, total)
cur1.close()
OR

(a) Predict the output of the following code


Name=”Jitesh kumar”
def test(a,b,c=10):
if c==10:
return len(Name)
if a==b:
return a+b+c
if a>b:
return a+b
print(test(2,3))
a=20
b=10
a=test(a,b,100)
print(a)
b=test(a,30,5)
print(b)
(b) A mysql table shop contains following columns
- ProductId
-PName
-PPrice
-Pquantity
The mysql database has following details
User =root
Password=base
database=business
The code given below calculate the sum of marks of all student. Fill in
the blanks
import ___________ #statement 1
con=mysql.connector.connect(host=’localhost’, user=’root’,
password=’base’, database=’business’))
cur1=con.cursor()
price=int(input(“enter price of product:- “))
product=”colgate”
sqlquery=“update shop set price={ } where
product={}.format(___________)” #statement 2
ur1.execute(___________) #statement 3
cur1.close()
Q.33 A csv file “ result.csv” contains record of student in following order 5
[rollno, name, sub1,sub2,sub3,total]
Initially student total field is empty string as example data is given
below
['1', 'amit', '40', '34', '90', '']
['2', 'bipin', '78', '34', '90', '']
['3', 'camal', '40', '45', '9', '']
A another file “final.csv” is created which reads records of “result.csv”
and copy all records after calculating total of marks into final.csv. The
contents of final.csv should be
['1', 'amit', '40', '34', '90', '164']
['2', 'bipin', '78', '34', '90', '202']
['3', 'camal', '40', '45', '9', '94']
(a) Define a function createcsv() that will create the result.csv file
with the sample data given above
(b) Define a function copycsv() that reads the result.csv and copy the
same data after calculating total field into final.csv file.
OR
(a) Define a function countresult() that count the total no of record
in “result.csv” file as described above
(b) Define a function finalstu() that reads the result.csv file as given
above and copy all the records into result.csv file except rollno 2
For example if result.cvs file contains
['1', 'amit', '40', '34', '90', '']
['2', 'bipin', '78', '34', '90', '']
['3', 'camal', '40', '45', '9', '']
The final.csv file will contain
['1', 'amit', '40', '34', '90', '']
['3', 'camal', '40', '45', '9', '']
SECTION E
Q.34 A table GAME has following structure and data 1+1
Gname NoPlayer Captain Won lost draw Location +2
Cricket 11 Dhoni 25 5 10 India
Cricket 11 Dhoni 10 5 3 Outside
TT 2 Vikash 17 20 5 India
TT 2 Vikash 4 20 7 Outside
Kabaddi 5 Suwan 30 3 1 India
Kabaddi 5 Suwan 10 1 0 Outside

I. Identify candidate key of the Game table, if any. Justify your


answer
II. How many rows will be in output if a query is executed using
DISTINCT clause in field Captain.
III.
(i) Which command will display the structure of GAME table
(ii) Write a sql query that will delete the record of captain
Dhoni in outside location
OR
(i) Write sql query to remove the column draw
(ii) Write sql query that change number of player for the
game kabaddi to 6

Q.35 A binary file library.dat contains records of library data in following


format
Book no, title, price , quantity
writedata() :- This function takes record of 5 books and store them into
library.dat file
calculate_value():- This function display the contents of library data
and also calculate the total cost of all the books available in library by
calculating sum of price*quantity of each book.

Fill in the blanks

import pickle
rec=[]
def writedata():
with open("library.dat","wb") as f:
for x in range(5):
bno=int(input("enter book no"))
title=input("enter title")
price=int(input("enter price"))
quantity=int(input("enter quantity")) 1
rec=[bno,title,price,quantity]
pickle.dump(_____________,f) # statement 1 1
def calculate_value():
with open("library.dat","_____________") as f: # statement 2 1
try:
sum1=_____________ # statement 3 1
while True:
_____________=pickle.load(f) # statement 4
sum1=sum1+ (int(rec[2]) * int(rec[3]))
print(“the cost of library is :- “,sum1)
except:
pass
Sample Paper 27
Computer Science (083)
CLASS XII 2023-24
CLASS-XII SUBJECT: COMPUTER SCIENCE
TIME: 3 HOURS M.M.: 70
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 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 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

(a) Statement-1 (b) Statement-2 (c) Statement-3 (d) Statement-4


10 Fill in the blanks: 1
_______ is the table constraint used to stop null values to be entered in the field.
(i) Unique
(ii) Not NULL
(iii) Not Empty
(iv) None
11 The correct syntax of read() function from text files is: 1
a. file_object.read()
b. file_object(read)
c. read(file_object)
d. file_object().read

12 Fill in the blank: 1


In SQL, we use _____ command to display the list of databases in the server.
(a) SELECT DATABASES;
(b) SELECT DATABASE;
(c) SHOW DATABASES;
(d) DESC;
13 Fill in the blank: 1
________ protocol is used to send mail.
(a) SMTP (b) FTP (c) POP (d) HTTPS
14 What will the following expression be evaluated to in Python? 1
10*1*2**4-4//4
15 Which function is used to display the maximum of records from table in a database? 1
(a) MAX (b) MAXIMUM (c) LARGEST (d) GREAT
16 To establish a connection with MySQL from Python which of the following functions is 1
used?
(a) connection() (b) connect() (c) open() (d) cursor()
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as:
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion (A): Global variable is declared outside the all the functions. 1
Reasoning (R): It is accessible through out all the functions.
18 Assertion (A): Binary files store all data in text format. 1
Reasoning (R): Binary files data remain in its original type.
Section B
19 Rajat has written the following Python code. There are some errors in it. Rewrite the 2
correct code and underline the corrections made.
DEF execmain():
x = input("Enter a number:")
if (abs(x)=x):
print ("You entered a positive number")
else:
x=*-1
print "Number made positive:"x
execmain()
20 Write two advantages of star topology and bus topology each. 2

OR

Briefly explain HTML and HTTP.


21 a. Find output generated by the following code: 1+1
mystr = “Hello I am a Human.”
print(mystr[::-3])

b. Write the output of the code given below:


p=10
q=20
p*=q//3
p=q**2
q+=p
print(p,q)
22 Differentiate between DDL and DML with one Example each. 2
23 a. Give the full form of the following: 2
i. URL
ii. FTP

b. What is the use of HTTP?


24 Predict the output of the following code: 2

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=",")

25 Answer the following : 2


i) Name the package imported for connecting Python with MySQL database.
ii) What is the purpose of cursor object?

OR

What is primary key in MySQL database? Give an example.

Section-C
26 a. Consider the following tables Trainer and Course: 1+2

What will be the output of the following statement?


SELECT * FROM TRAINER NATURAL JOIN COURSE;

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.”

The method/function should display:


THIS IS IMPORTANT TO NOTE THAT
WE ALL ARE EXPECTED TO DO HARD WORK.
28 a. Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and 3
Posting given below:

i. SELECT Department, count(*) FROM Teacher GROUP BY Department;


ii. SELECT Max(Date_of_Join),Min(Date_of_Join) FROM Teacher;
iii. SELECT Teacher.name,Teacher.Department, Posting.Place
FROM Teacher, Posting
WHERE Teacher.Department = Posting.Department AND Posting.Place=”Delhi”;
iv. SELECT Gender, COUNT(Gender) FROM Teacher GROUP BY Gender;

b. Write the command to view the schema of the table Teacher.


29 Python funtion oddeve(L) to print positive numbers in a list L. 3
Example:
Input: [4, -1, 5, 9, -6, 2, -9, 8]
Output: [4, 5, 9, 2, 8]
30 Write a function AddCustomer(Customer) in Python to add a new Customer information 3
into the stack (list) CStack and display the information.

OR

Write a function DeleteCustomer() to delete a Customer information from a list of


CStack. The function delete the name of customer from the stack.
Example: If the stack contains [“Abhinav”,”Vimank”],
the output should be:
Vimank
Abhinav
Section-D
31 Prithvi Training Institute is planning to set up its centre in Jaipur with four specialized 5
blocks for Medicine, Management, Law courses along with an Admission block in
separate buildings. The physical distances between these blocks and the number of
computers to be installed in these blocks are given below. You as a network expert have
to answer the queries raised by their board of directors as given in (i) to (v).

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

a. What is Degree and Cardinality of the above table?


b. Which field should be made as the primary key? Justify your answer.
c. Write the query to:
i. Insert a record: (107,Bhoomi,Delhi,2001-12-15,90000)
ii. Increase the salary by 1% for the trainers whose salary is more than 80000
OR
i. Delete the record of Richa
ii. Add a new column remarks of VARCHAR type with 50 characters.
Section E
35 Priti of class 12 is writing a program to create a CSV file “emp.csv”. She has written the 1+1
following code to read the content of file emp.csv and display the employee record +2
whose name begins from “S‟ also show no. of employee with first letter “S‟ out of total
record. As a programmer, help her to successfully execute the given task.
Consider the following CSV file (emp.csv):
1,Peter,3500
2,Scott,4000
3,Harry,5000
4,Michael,2500
5,Sam,4200

import _____ # Line-1


def snames():
with open(______) as csvfile: # Line-2
myreader = csv.___ (csvfile, delimiter=",") # Line-3
count_rec=0
count_s=0
for row in myreader:
if row[1][0].lower() == "s":
print(row[0],",",row[1],",",row[2])
count_s += 1
count_rec += 1
print(count_rec, count_s)
i. What should be written in Line-1?
ii. In which mode should Priti open the file to print the data?
iii. What should be written in Line-2 and Line-3?
Sample Paper 28
Computer Science (083)
CLASS XII 2023-24

Maximum marks: - 70 Time: - 3 Hr


General Instructions: -
• This question paper contains 5 sections. Section A to E
• All questions are compulsory
• Section A has 18 questions of 1 mark each.
• Section B has 7 questions very short answer type of 2 marks each
• Section C has 5 questions short answer type of 2 marks each
• Section D has 3 questions long answer type of 2 marks each
• Section E has 2 questions of 4 marks each. One internal choice is given in Q35
against part C only
• All programming questions are based on Python Programming language.
SECTION A
Q.1 State Ture of False 1
True is not False in [True, False]
Q.2 Which is unordered sequence 1
(a) tuple (b) list (c) dictionary (d) String
Q.3 What will be the content of dictionary d after executing the following 1
code
d={1:100,2:200}
t=(1,2,3)
d.fromkeys(t)
Q.4 What will be the output of the following code 1
3>2>1*5
(a) Ture (b) False (c) Error (d) None of all
Q.5 Predict the result of the following code 1
“@”.join(“abc-gmail.com”.split(“-“)
Q.6 Which open method of file handling does not require file to be close 1
explicitly.
Q.7 Which pair of SQL Statement is not from the same category of SQL 1
command
(a) create, alter
(b) insert, delete
(c) delete, drop
(d) update, delete
Q.8 Choose valid statement 1
(a) insert command is part of DDL
(b) insert command insert a row at beginning
(c) insert command can insert a row any where
(d) insert command insert many rows
Q.9 Mr khan has written following python code. Choose the one which will 1
not execute
(a) t=(10,20)+(30,40)
(b) t=(10,20)+(30)
(c) t=10+(10)
(d) t=(10,20)+(30,)
91
Q.10 A key of a table is not primary key but can be selected as primary key. 1
Choose the correct answer for the above given statement
(a) Secondary key (b) Alter table
(c) Candidate key (d) Foreign key
Q.11 Correct syntax to open a binary file in read mode is 1
(a) F=open(“abc.dat”,”b”,”r”)
(b) F=open(“abc.dat”,”br”)
(c) F=open(“abc.dat”,”rb”)
(d) F=open(“abc.dat”,”r”,”b”)
Q.12 The correct definition of column ‘alias’ is 1
(a) A permanent new name of column
(b) A new column of a table
(c) A view of existing column with different name
(d) A column which is recently deleted
Q.13 Fill in the blank 1
The service for remote login is called ____________
(a) Telnet
(b) Web browser
(c) Firewall
(d) Cookies
Q.14 Correct statement for ab is 1
(a) math.pow(a,b)
(b) a**b
(c) both a and b are correct
(d) math.sqrt(a,b)
Q.15 To view the list of tables of a database, the correct command is ____ 1
(a) list tables
(b) show tables
(c) display tables
(d) view tables
Q.16 Using python mysql connectivity the correct code to display all the 1
available databases of Mysql with the help of a cursor mcur is
(a) mcur.execute(“show database”)
(b) mcur.execute(“desc database”)
(c) mcur.execute(“show databases”)
(d) mcur.execute(“desc databases”)
Question 17 and 18 are ASSERTION AND REASONING based. Mark the
correct choice as
(a) A and R are True and R is correct explanation of A
(b) A and R are True and R is not correct explanation of A
(c) A is True but R is False
(d) A is False but R is True
Q.17 Assertion(A): if an existing file whose size was 50 Byte is opened in 1
write mode and after writing another 50 Byte into file it is closed. The
file size is 100 Byte after closing.
Reason(R) : File size will remain 50 Byte as it was not opened in
append mode so old content will be lost.
Q.18 Assertion(A): A function can take no argument or any number of 1
argument and writing of return keyword is not compulsory
Reason(R) : If we do not write return key word the function will return
None value.
92
SECTION B
Q.19 The following code has some error. Rewrite the code underling the 2
correction made.
def funpara(a=20,b=10,c)
if a>b:
print(“first is big”)
else:
print(“second is big”)
Return(“Third number is missing”)

Q.20 Write one advantage and one disadvantage of circuit switching 2


OR
Which language is the most suitable language to create static web pages?
Does your suggested language has pre defined tags.
Q.21 Write correct code to produce output “retupmoc” if a variable s1 1
contains “computer”
(a) s1=”computer”
print(s1[_______])

1
(b) Write the correct output of following code
d={1:100,2:200}
for x,y in d:
print(x,d[x],end=’’)
Q.22 How many candidate key and primary key a table can have? Can we 2
declared combination of fields as a primary key?
Q.23 (a) Which protocol is used to upload files on web server? 2
(b) Expand the term TCP/IP
Q.24 Choose the best option for the possible output of the following code 2
import random
L1=[random.randint(0,10) for x in range(3)]
print(L1)
(a) [0,0,7] (b) [9,1,7] (c) [10,10,10] (d) All are possible

OR
import random
num1=int(random.random()+0.5)
What will be the minimum and maximum possible values of variable
num1
Q.25 Mrs sunita wrote a query in SQL for student table but she is not getting 2
desired result
select * from student where fee = NULL;
Rewrite the above query so she well gets desired result
OR
What is the difference between delete and drop command?
SECTION C
Q.26 (a) What is the difference between not-equi join and equi join. 1+2
(b) Consider the TEACHER table given below
TEACHER SUBJECT GENDER AGE
MANOJ SCIENCE MALE 38
NIKUNJ MATHS MALE 40
93
TARA SOCIAL FEMALE 38
SCIENCE
SUJAL SCIENCE MALE 45
RAJNI SCIENCE FEMALE 52
GEETA HINDI FEMALE 31

Write OUTPUT of the following queries


(a) select count(distinct subject) from teacher;
(b) select count(*) from teacher group by gender;
(c) select sum(age) from teacher where age >40 group by gender;
(d) select count(*) from teacher group by subject having count(*)>1;
Q.27 Write a function readstar() that reads a text file STORY.TXT and display 3
line numbers that contains * anywhere. For example, the file contains
The multiplication symbol * has many meaning
The * can also be used as pointer
The addition symbol + also has many meaning
The output of the readstar() should be
Line no 1 has star
Line no 2 has star
OR
Write a function word5count() that count number of words whose
length is more than 5 characters in above given STORY.TXT file.
Q.28 (a) Consider the doctor and patient table and write the output of (i) to 3
(iv)
Doctor
docid Dname Specialization Outdoor
D1 MANISH PHYSICIAN MONDAY
D2 PARESH EYE FRIDAY
D3 KUMAR ENT SATURDAY
D4 AKASH ENT TUESDAY

Patient
Pid Pname did Date_visit
P1 Lal singh D2 2022-04-25
P2 Arjun D1 2022-05-05
P3 Narender D4 2022-03-13
P4 Mehul D3 2022-07-20
P5 Naveen D2 2022-05-18
P6 Amit D1 2022-01-22

(I) select count(*) from patient where date_visit like ‘%2_’;


(II) select count(*) from doctor group by specialization;
(III) select a.dname, b.pname from doctor a, patient b where
a.docid=b.did;
(IV) select dname from doctor,patient where docid=did and
pname=’Arjun’;

(c) With reference to RDBMS define attribute.

Q.29 Write a function exchange() that accept two list as parameter. The two 3
94
list contains integer values. The function should return a single list that
stores all the values of both list in sorted form. For example
L1=[4,20,9,15]
L2= [7,0,70]
The returned list should be [0,4,7,9,15,20,70]
Q.30 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]

After Push_na() the contains of Lnameage stack is


[(‘raju’,59),(‘amit’,51)]
The output of first execution of pop_na() is
The name removed is amit
The age of person is 51
OR
A dictionary stu contains rollno and marks of students. Two empty list
stack_roll and stack_mark will be used as stack. Two function push_stu()
and pop_stu() is defined and perfom following operation
(a) Push_stu() :- It reads dictionary stu and add keys into stack_roll
and values into stack_marks for all students who secured more
than 60 marks.
(b) Pop_stu() :- it removes last rollno and marks from both list and
print “underflow” if there is nothing to remove
For example
stu={1:56,2:45,3:78,4:65,5:35,6:90}

values of stack_roll and stack_mark after push_stu()


[3,4,6] and {78,65,90}
SECTION D
Q.31 The BPL corporation has 4 offices(Admin office, account office, marketing
office and training office) situated at different locations of a metro city.
Company is planning to connect all its offices through network. It wants
to control all the office from admin office and all kind of work done in its
office has been computerized. Now it wants to establish network among
all its offices. Distance between its offices and number of computers in
each office is given. You have to suggest best option for the following
issues.

Distance between each offices No of computers in


each offices
Admin to account 40 km Admin 120
Admin to 20 km Account 20
marketing
95
Admin to training 25 km Training 50
Training to account 70 km marketing 30 1
Training to 65 km
marketing 1
Marketing to 55 km
account 1

(i) Which device should be used in each office to connect each 1


computer of the office 1
(ii) To protect all incoming and outgoing data from hackers which
hardware or software should be used.
(iii) You are to suggest a plan to protect all individual computers
from Phishing web sites, virus, trojan and worm attack.
(iv) Suggest the best cable layout to connect all the computers of
the company
(v) Suggest where SERVER should be installed.
Q.32 (a) Predict the output of the following code 2+3
email=”Way2sma@gmail.com”
for x in email.split(“@”):
if ‘a’ in x:
print(x[0:3]
if x in “.”:
print(x[0:5])
(b)
A mysql table class contains following columns
-Roll no
-Name
-Marks
The mysql database has following details
User =‘python’
Password=’test’
database=student

The code given below calculate the sum of marks of all student. Fill in
the blanks

import mysql.connector
con=_____________________.connect(host=’localhost’, user=’python’,
password=’test’, database=’student’) # statement 1
cur1=con.cursor()
cur1.____________(“select * from class”) # statement 2
total=0
for x in __________: # statement 3
total=total+int(x[2])
print(“total marks of all students :- “, total)
cur1.close()
OR

(a) Predict the output of the following code


Name=”Jitesh kumar”
def test(a,b,c=10):
96
if c==10:
return len(Name)
if a==b:
return a+b+c
if a>b:
return a+b
print(test(2,3))
a=20
b=10
a=test(a,b,100)
print(a)
b=test(a,30,5)
print(b)
(b) A mysql table shop contains following columns
- ProductId
-PName
-PPrice
-Pquantity
The mysql database has following details
User =root
Password=base
database=business
The code given below calculate the sum of marks of all student. Fill in
the blanks
import ___________ #statement 1
con=mysql.connector.connect(host=’localhost’, user=’root’,
password=’base’, database=’business’))
cur1=con.cursor()
price=int(input(“enter price of product:- “))
product=”colgate”
sqlquery=“update shop set price={ } where
product={}.format(___________)” #statement 2
ur1.execute(___________) #statement 3
cur1.close()
Q.33 A csv file “ result.csv” contains record of student in following order 5
[rollno, name, sub1,sub2,sub3,total]
Initially student total field is empty string as example data is given
below
['1', 'amit', '40', '34', '90', '']
['2', 'bipin', '78', '34', '90', '']
['3', 'camal', '40', '45', '9', '']
A another file “final.csv” is created which reads records of “result.csv”
and copy all records after calculating total of marks into final.csv. The
contents of final.csv should be
['1', 'amit', '40', '34', '90', '164']
['2', 'bipin', '78', '34', '90', '202']
['3', 'camal', '40', '45', '9', '94']
(a) Define a function createcsv() that will create the result.csv file
with the sample data given above
(b) Define a function copycsv() that reads the result.csv and copy the
same data after calculating total field into final.csv file.

97
OR
(a) Define a function countresult() that count the total no of record
in “result.csv” file as described above
(b) Define a function finalstu() that reads the result.csv file as given
above and copy all the records into result.csv file except rollno 2
For example if result.cvs file contains
['1', 'amit', '40', '34', '90', '']
['2', 'bipin', '78', '34', '90', '']
['3', 'camal', '40', '45', '9', '']
The final.csv file will contain
['1', 'amit', '40', '34', '90', '']
['3', 'camal', '40', '45', '9', '']
SECTION E
Q.34 A table GAME has following structure and data 1+1
Gname NoPlayer Captain Won lost draw Location +2
Cricket 11 Dhoni 25 5 10 India
Cricket 11 Dhoni 10 5 3 Outside
TT 2 Vikash 17 20 5 India
TT 2 Vikash 4 20 7 Outside
Kabaddi 5 Suwan 30 3 1 India
Kabaddi 5 Suwan 10 1 0 Outside

I. Identify candidate key of the Game table, if any. Justify your


answer
II. How many rows will be in output if a query is executed using
DISTINCT clause in field Captain.
III.
(i) Which command will display the structure of GAME table
(ii) Write a sql query that will delete the record of captain
Dhoni in outside location
OR
(i) Write sql query to remove the column draw
(ii) Write sql query that change number of player for the
game kabaddi to 6

Q.35 A binary file library.dat contains records of library data in following


format
Book no, title, price , quantity
writedata() :- This function takes record of 5 books and store them into
library.dat file

calculate_value():- This function display the contents of library data


and also calculate the total cost of all the books available in library by
calculating sum of price*quantity of each book.

Fill in the blanks

import pickle
rec=[]
def writedata():
with open("library.dat","wb") as f:
98
for x in range(5):
bno=int(input("enter book no"))
title=input("enter title")
price=int(input("enter price"))
quantity=int(input("enter quantity")) 1
rec=[bno,title,price,quantity]
pickle.dump(_____________,f) # statement 1 1
def calculate_value():
with open("library.dat","_____________") as f: # statement 2 1
try:
sum1=_____________ # statement 3 1
while True:
_____________=pickle.load(f) # statement 4
sum1=sum1+ (int(rec[2]) * int(rec[3]))
print(“the cost of library is :- “,sum1)
except:
pass

99
Sample Paper 29
Computer Science (083)
CLASS XII 2023-24

Maximum Marks: 70 Time Allowed: 3 hours

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice
isgiven in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

QNo SECTION-A Marks


1 Which of the following is not a keyword python? 1
(a) Eval (b)assert (c) nonlocal (d) pass
2 Which of the following is an invalid datatype in Python?
(a) list (b) Dictionary (c)Tuple (d)Class 1
3 What will be the output for the following Python statement?
D={‘AMIT’:90,’RESHMA’:96,’SUKHBIR’:92,’JOHN’:95}
print(‘JOHN’ in D, 90 in D, sep=”#”) 1
(a)True#False (b) True#True (c) False#True (d) False#False
4 Consider the given expression:
True and False or not True
Which of the following will be correct output if the given expression is 1
evaluated?
(a) True (b) False (c) NONE (d) NULL
5 Select the correct output of the code:
count = 0
while(True):
if count % 3 == 0:
print(count, end = " ")
1
if(count > 15):
break;
count += 1
(a) 0 1 2 ….. 15 (b)Infinite loop
(c) 0 3 6 9 12 15 (d) 0 3 6 9 12
6 Which of the following is not a valid mode to open a file?
1
(a) ab (b) r+ (c) w+ (d) rw

106
7 The attribute which have al the properties of primary key.
(a) foreign key (b)alternate key 1
(c) candidate key (d) Both (a) and (c)
8 Which command is used to change some values in existing rows?
(a) UPDATE (b) ORDER (c) ALTER (d) CHANGE 1

9 What possible output(s) are expected to be displayed on screen at the time of


execution of the program from the following code?
import random
points=[20,40,10,30,15]
points=[30,50,20,40,45]
begin=random.randint(1,3) 1
last=random.randint(2,4)
for c in range(begin,last+1):
print(points[c],"#")
(a) 20#50#30# (b) 20#40#45
(c) 50#20#40# (d) both (b) and (c)
10 Fill in the blank:
is an attribute whose value is derived from the primary key
of some other table. 1
(a) Primary Key (b) Foreign Key
(c) Candidate Key (d) Alternate Key
11 Which function is used to split a line in columns?
1
(a)split( ) (b) spt( ) (c) split_line( ) (d) all of these
12 Consider the following statement:
Select * from product order by rate ……………….. , item_name……….. .
Which of the following option should be used to display the ‘rate’
1
from greater to smaller and ‘name’ in alphabetical order?
(a)ASC, DESC (b)DESC,ASC
(c) Descending, Ascending (d)Ascending, Descending
13 Which switching technique follows the store and forward mechanism?
(a) Circuit switching (b) message switching 1
(c) packet switching (d) All of these
14 What will the following expression be evaluated to in Python?
print(16-(3+2)*5+2**3*4) 1
(a) 54 (b) 46 (c) 23 (d) 32
15 What values does the count(<column_name>) function ignore?
1
(a) Repetitive values (b) Null values (c) Characters (d) Integers
16 To get all the records from the result set, you may use…………….
(a) cursor.fetchmany() (b) cursor.fetchall()
1
(c) select * from <table name); (d) cursor.allrecords()

107
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
1
(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 the function calls.
Reasoning (R):- when you use keyword arguments in a function call, the 1
caller identifies the arguments by parameter name.
18 Assertion (A): CSV stands for Comma Separated Values
Reason (R): CSV files are a common file format for transferring and storing 1
data.
SECTION-B
19 Observe the following Python code very carefully and rewrite it after 2
removing all syntactical errors with each correction underlined.
DEF execmain():
x = input("Enter a number:")
if (abs(x)== x)
print("You entered a positive number")
else:
x=*1
print("Number made positive:" x )
20 Write two points of difference between Packet Switching and Message 2
Switching.
OR
Write two points of difference between XML and HTML.
21 (a)Given is a Python string declaration: 1+1 =2
S=”python rocks”
Write the output of: print(S[7:11]*3)
(b) Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.keys())
22 Differentiate between Primary Key and Candidate Key. 2
23 (a) Write the full forms of the following: 1+1=2
(i)IMAP (ii) POP
(b) Define VoIP?
24 Predict the output of the Python code given below: 2
def Alter(P=15,Q=10):
P=P*Q
Q=P/Q
print(P,"#",Q)
return Q
A=100

108
B=200
A=Alter(A,B)
print(A,"$",B)
B=Alter(B)
print(A,"$",B)
A=Alter(A)
print(A,"$",B)
OR

Predict the output of the Python code given below:


t=tuple()
t=t + tuple(‘Python’)
print(t)
print(len(t))
t1=(10,20,30)
print(len(t1))
25 Differentiate between DDL and DML commands with suitable example. 2
OR
What is the difference between WHERE and HAVING clause of SQL
statement?
SECTION – C
26 (a)Consider the following tables – Bank_Account and Branch: 1+2=3
Bank_Account:
ACode Name Type
A01 Amit Savings
A02 Parth Current
A03 Mira Current
Branch:
ACode City
A01 Delhi
A02 Jaipur
A01 Ajmer
What will be the output of the following statement?
SELECT * FROM Bank_Account NATURAL JOIN Branch;
(b) Give the output of the following sql statements as per table given above.
Table : SPORTS
StudentNo Class Name Game1 Grade1 Game2 Grade2
10 7 Sammer Cricket B Swimming A
11 8 Sujit Tennis A Skating C
12 7 Kamal Swimming B Football B
13 7 Venna Tennis C Tennis A
14 9 Archana Basketball A Cricket A
15 10 Arpit Cricket A Athletics C
i. SELECT COUNT(*) FROM SPORTS.

109
ii. SELECT DISTINCT Class FROM SPORTS.
iii. SELECT MAX(Class) FROM SPORTS;
iv. SELECT COUNT(*) FROM SPORTS GROUP BY Game1;
27 Write a method in Python to read lines from a text file DIARY.TXT, and 1+2
display those lines, which are starting with an alphabet ‘A’.
For example If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The display() function should display the output as:
An apple a day keeps the doctor away.
A marked difference will come in our country.
OR
Write a method/function DISPLAYWORDS() in python to read lines from
a text file STORY.TXT, and display those words, which are less than 4
characters.
28 (a) consider the following tables School and Admin and answer the following 2+1=3
(a) questions: TABLE: SCHOOL
CODE TEACHER SUBJECT DOJ PERIODS EXPERIENCE
1001 RAVI ENGLISH 12/03/2000 24 10
1009 PRIYA PHYSICS 03/09/1998 26 12
1203 LISA ENGLISH 09/04/2000 27 5
1045 YASH RAJ MATHS 24/08/2000 24 15
1123 GAGAN PHYSICS 16/07/1999 28 3
1167 HARISH CHEMISTRY 19/10/1999 27 5
1215 UMESH PHYSICS 11/05/1998 22 16

TABLE : ADMIN
CODE GENDER DESIGNATION
1001 MALE VICE PRINCIPAL
1009 FEMALE COORDINATOR
1203 FEMALE COORDINATOR
1045 MALE HOD
1123 MALE SENIOR TEACHER
1167 MALE SENIOR TEACHER
1215 MALE HOD

Give the output of the following SQL queries:


i. Select Designation, count(*) from Admin Group by Designation
having count(*)<2;
ii. Select max(experience) from school;
iii. Select teacher from school where experience >12 order by teacher;
iv. Select count(*), gender from admin group by gender;

110
(b) Write SQL command to delete a table from database.

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


argument to the function. The function returns another list named‘newList’
that stores the indices of all Non-Zero Elements of L.
For example:
If L contains [2,4,0,1,0,6]
The newList will have - [0,1,3,5]
30 Write Add_New(Book) and Remove(Book) methods in Python to Add a new 1+2
Book and Remove a Book from a List of Books, considering them to act as
PUSH and POP operations of the data structure stack.
OR

Aalia has a list containing 10 integers. You need to help him create a program
with separate user defined functions to perform the following operations
based on this list.
➢ Traverse the content of the list and push the even numbers into a stack.
➢ Pop and display the content of the stack.
For example:
If the sample content of the list is as follows:
N=[12,13,34,56,21,79,98,22,35,38]
Sample output of the code should be:
38 22 98 56 34 12
SECTION – D
31 Trine Tech Corporation (TTC) is a professional consultancy company. The 5
company is planning to set up their new offices in India with its hub at
Hyderabad. As a network adviser, you have to understand their requirement
and suggest them the best available solutions. Their queries
are mentioned
as (i) to (v) below.

111
a) Which will be the most appropriate block, where TTC should plan to
install their server?
b) Draw a block to block cable layout to connect all the buildings in the
most appropriate manner for efficient communication.
c) What will be the best possible connectivity out
of the following, you will suggest to connect the new setup of offices in
Bengalore with its London based office.
● Satellite Link
● Infrared
● Ethernet
d) Which of the following device will be suggested by you to connect each
computer in each of the buildings?
● Switch
● Modem
● Gateway
e) Company is planning to connect its offices in Hyderabad which is less
than 1 km. Which type of network will be formed?
32 (a) Write the output of the code given below: 5
p=25
def
sum(q,r=3):
global p
p=r+q*
*2
print(p, end= '#')
a=6
b=4
sum(a,b)
sum(r=5,q=1)
(c) The code given below inserts the following record in the table
mobile:
import mysql.connector
mycon = mysql.connector.connect (host = “localhost”, user = “Admin”,
passwd = “Admin@123”, database = “connect”)
cursor = mycon. () # Statement 1
sql = “INSERT INTO Mobile (Name, Model, Price, Qty) VALUES (%s, %s, %s,
%s)” val = (“Samsung”, “Galaxy Pro”, 28000, 3)
cursor… (sql,val) #Statement 2
mycon. #Statement 3
112
Write the missing statement: Statement1 , Statement2 and Statement3
OR
(a) Predict the output of the code given below:
L1 = [100,900,300,400,500]
START = 1
SUM = 0
for C in range (START,4):
SUM = SUM + L1[C]
print (C,":",SUM)
SUM = SUM + L1[0]*10
print (SUM)
(b) The code given below reads the following record from the tablenamed
student and displays only those records who have marks greater than
80:
RollNo – integer
Name – string
Clas – integer
Marks – integer
Note the following to establish connectivity between Python andMYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named kvs.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those
students whose marks are greater than 80.
Statement 3- to read the complete result of the query (records whose
marks are greater than 80) into the object named data, from thetable
studentin the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",passwo
rd="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)
33 a. What is the advantage of using a csv file for permanent storage? 1+2+2=5
b. Write a Program in Python that defines and calls the following user
defined functions:
(i) ADD() – To accept and add data of a student to a CSV file
‘record.csv’. Each record consists of a list with field elements as sid,
name and class to store student_id, student _name and class
respectively.
(ii) COUNTR() – To count the number of records present in the CSV file
named ‘record.csv’.
113
OR
a. Write difference between a binary file and a csv file.
b. Write a Program in Python that defines and calls the following user
defined functions:
(i) add() – To accept and add data of an employee to a CSV file
‘empdata.csv’. Each record consists of a list with field
elements as eid, ename and salaryto store empid, emp name
and emp salary respectively.
(ii) search()- To display the records of the emp whose salary is more
than 10000.
SECTION -E
34 Mayank creates a table RESULT with a set of records to maintain the marks 4
secured by students in sub1, sub2, sub3 and their GRADE. After creation of
the table, he has entered data of 7 students in the table.
Table : RESULT
ROLL_NO SNAME sub1 sub2 sub3 GRADE
101 KIRAN 366 410 402 I
102 NAYAN 300 350 325 I
103 ISHIKA 400 410 415 I
104 RENU 350 357 415 I
105 ARPITA 100 75 178 IV
106 SABRINA 100 205 217 II
107 NEELIMA 470 450 471 I
103 ISHIKA 400 410 415 I
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as
Primary key.
(ii) If two columns are added and 2 rows are deleted from the table
result, 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- 108, Name- Aaditi, sub1- 470, sub2-444, sub3- 475,
Grade– I.
b. Increase the sub2 marks of the students by 3% whose name
begins with ‘N’.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of students securing Grade-IV.
b. Add a column REMARKS in the table with datatype as varcharwith 50
characters.
35 Anamika is a Python programmer. She has written a code and created a 4
binary file data.dat with sid, sname and marks. The file contains 10 records.
She now has to update a record based on the sid entered by the user and
update the marks. The updated record is then to be written in the file
extra.dat. The records which are not to be updated also have to be written
to the file extra.dat. If the sid is not found, an appropriate message should
to be displayed.
As a Python expert, help him to complete the following code based on
requirement given above:
114
import ……………. #Statement 1
def update_data():
rec={}
fin=open("data.dat","rb")
fout=open(" ") #Statement 2
found=False
eid=int(input("Enter student id to update their marks :: "))
while True:
try:
rec= #Statement 3
if rec["student id"]==sid:
found=True
rec["marks"]=int(input("Enter new marks:: "))
pickle. #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The marks of student id ",sid," hasbeen updated.")
else:
print("No student with such id is not found")
fin.close()
fout.close()
(i) Which module should be imported in the program? (Statement1)
(ii) Write the correct statement required to open a temporary file
named extra.dat. (Statement 2)
(iii) Which statement should Anamika fill in Statement 3 to read the
data from the binary file, data.dat and in Statement 4 towrite the updated
data in the file, extra.dat?

115
Sample Paper 30
Computer Science (083)
CLASS XII 2023-24
Maximum Marks: 70 Time Allowed: 3
hoursGeneral Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Sections A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice
isgiven in Q.35 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 1
following functions:
a. floor ( )
b. randomint ( )
2. To use function of any module, we have to use ____________ (command) 1
before the use 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 1
group the 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

122
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 1
“Students.txt” 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’)

12. Fill in the blank: 1


The ………………. clause, places condition with aggregate functions .
a. HAVING b. WHERE c. IN d.BETWEEN
13. Write the full forms of: 1
a. PPP
b. VOIP
14. Find the output: 1
tuple1 = (10,12,14,16,18,20,22,24,30)
print( tuple1[5:7] )
15. Which of the following is not an aggregate function? 1
a. AVG b. MAX c. JOIN d.COUNT
16. Name the module used to establish a database connection with a python 1
program.
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 1
pseudo-random 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 2
the use of if-else 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.

123
21. Write the output after evaluating he following 1
expressions:
a) k= 7 + 3 **2 * 5 // 8 – 3
print(k)
b) m= (8>9 and 12>3 or not 6>8) 1
print(m)
22. What do you understand by table constraint in a table? Give a suitable 2
example in support 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

Predict the output of the Python code given below:


T= [“20”, “50”, “30”, “40”]
Counter=3
Total= 0
for I in [7,5,4,6]:
newT=T[Counter]
Total= float (newT) + I
print(Total)
Counter=Counter-1
25. Rohit wants to increase the size of the column FeeAmount by 5, which is 2
possible category out of DML / DDL of command he has to use to:
(Write DDL or DML alongwith command / query)
Display the structure of table (DDL or DML)
Increase the size of column FeeAmount by 5 (DDL or DML)
OR
Differentiate between char(n) and varchar(n) data types with respect to
databases.

SECTION C

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?

124
(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=2;
(iii) Select AVG(STIPEND) from STUDENT where AVERAGE>=65;
(iv) Select COUNT(distinct SUBJECT) from STUDENT;
27. Write a definition of a function calculate () which count the 3
number of digits in a file “ABC.txt”.
OR
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

EmpCode Ename Salary JoinDate


E001 Raman 55000 2019-10-11
E002 Neha 65000 2019-11-20
E003 Priya 60000 2020-01-28
E004 Raghav 58000 2020-02-16
(i) Select ename, salary from emp where name like ‘_r%’
(ii) Select count(salary) from emp where joindate>’2019-11-28’
(iii) Select max(joindate), min(joindate) from emp
(b) Write the command to list all the databases in MySQL.
29. Write definition of a Method MSEARCH(STATES) to display all the state 3
names from a 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

125
30. Write a function in Python push(S,item), where S is stack and item is 3
element to be 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.
Distance Between Blocks No. of Computers
Block A to Block B 50m Block A 25
Block B to Block C 150m Block B 50
Block C to Block D 25m Block C 125
Block A to Block D 170m Block D 10
Block B to Block D 125m
Block A to Block C 90m
1
(i) Suggest a cable layout of connection between the blocks (Diagram).
1
(ii) Suggest the most suitable block to host the server along with the reason.
(iii) Where would you place Repeater devices? Answer with justification. 1
(iv) The organization is planning to link its front office situated in the city
in a hilly region where cable connection is not feasible, suggest 1
an economic way to connect it with reasonably high speed. 1
(v) Where would you place Hub/Switch? Answer with justification.
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. ()

126
query=”select * from stmaster”
cur.execute( )
resultset=cur.fetchmany(3)
for row in resultset:
print(row)
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 5
user id and 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()

with open('d:\\a.csv','r') as newFile:


newFileReader = csv. (newFile) #Line 3
for row in newFileReader:
print (row) #Line 4
newFile. #Line 5

a) Name the module he should import in Line 1


b) Fill in the blank in line 2 to write the row.
127
c) Fill in the blank in line 3 to read the data from csv file.
d) Write the output while line 4 is executed.
e) Fill in the blank in line 5 to close the file.
OR
ANSHU is writing a program to search a name in a CSV file “MYFILE.csv”. He
has written thefollowing code. As a programmer, help him to successfully
execute the given task.
import # Statement 1
f = open("MYFILE.csv", ) # Statement 2
data = ( f ) # Statement 3
nm = input("Enter name to be searched: ")
for rec in data:
if rec[0] == nm:
print (rec)
f. ( ) # Statement 4

(a) Name the module he should import in Statement 1.


(b) In which mode, MOHIT should open the file to search the data in the file in
statement 2?
(c) Fill in the blank in Statement 3 to read the data from the file.
(d) Fill in the blank in Statement 4 to close the file.
(e) Write the full form of CSV.
SECTION-E
34. Dinesh creates a table COMPANY with a set of 06 records. 1+1+2

C_ID F_ID Cname Fees


C21 102 Grid Computing 40000
C22 106 System Design 16000
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000
Based on the data given above answer the following questions:
(a)Identify the most appropriate column, which can be considered as
Primary key.
(b) If 3 columns are added and 2 rows are deleted from the table result,
what will be the new degree and cardinality of the above table?
(c) Write the statements to:
(i) delete a record which has C_ID as C24
(ii) Increase the Fee of all by 500.
OR (Option for part (C) only)
(i) Add a column PLACE in the table with datatype as varchar with
20 Characters.
(ii) Query to display all the records.

128
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).

129
Sample Paper 31
Computer Science (083)
CLASS XII 2023-24

Date: Max. Marks: 70


Subject: Computer Science (083) Time: 3 Hours
______________________________________________________________________________
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each. Three internal
choice is given in Q19,Q21 and Q24
5. Section C has 05 Short Answer type questions carrying 03 marks each. One internal choice is
given in Q28
6. Section D has 02 Long Answer type questions carrying 04 marks each.
7. Section E has 03 questions carrying 05 marks each. Two internal choice is given in Q34 and
Q35.
8. All programming questions are to be answered using Python Language only.

SECTION- A
Sl. No Question M
1 State True or False: 1
“In a Python program, the variable declaration is implicit”
2 Select the DDL command from the following: 1
a) SELECT
b) INSERT
c) DELETE
d) DROP
3 What will be the output of the following statement 1

print(46%2**3+4/11)
a) 6
b)6.0
c)6.3
d)6.5

1
4 Predict the correct output of the code: 1

5 Which of the following will display information about all the employee table, whose 1
names contains second letter as "S"?
(a) SELECT * FROM EMP WHERE NAME LIKE "_S%";
(b) SELECT * FROM EMP WHERE NAME LIKE "%S_";
(c) SELECT * FROM EMP WHERE NAME LIKE "_ _S%";
(d) SELECT * FROM EMP WHERE NAME="S%"
6 Rearrange the following terms in increasing order of data transfer rates. 1
Gbps, Mbps, Tbps, Kbps, bps
7 Which of the following will delete key-value pair for key = “Orange” from a dictionary 1
D1?
a. delete D1("Orange")
b. del D1["Orange"]
c. del.D1["Orange"]
d. D1.del["Orange"]
8 Vamshi creates many tables under the database named “Exam”, now she wants to list 1
out all the tables created in that. Write a SQL query to execute the above condition.
9 Which of the following statement(s) would give an error during execution of the 1
following code?
tup = (20,35,45,50,85,80)
print(tup[1]) #Statement 1
tup[2]=25 #Statement 2
print(tup[3]+50) #Statement 2
print(min(tup)) #Statement 3
tup[4]=80 #Statement 4
Options:
a. Statement 1 & statement 2
b. Statement 2
c. Statement 3
d. Statement 2 & statement 4
10 Out of the following, which is the costliest wired and wireless medium of transmission? 1
Infrared, Coaxial cabel, optical fibre microwave, satellite,twisted pair cable.
11 Identify the type of network 1

2
12 Mr. Soman created a table named “Student” with the fields Rollno, Student_name, Class, 1
and Section. He entered several rows into the table. When he displayed the entered rows,
he found that Rollno’s were duplicated without knowing it. If you were in Soman’s
position, what type of constraints would you apply to avoid the above data redundancy?
13 State whether the following statement is True or False: 1
An exception may be raised even if the program syntax is wrong.
14 The UPDATE SQL clause can 1
a) Update only one row at a time
b) Update more than one row at a time
c) Delete more than one row at a time
d) Delete only one row at a time
15 A client server network is also called as ___________. 1
a) Peer-to-peer network
b) Master-Slave network
c) Dedicated
d) Non-dedicated
16 Mention the modes in which the file pointer is at the end of the line. 1

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) : Default arguments in Python functions should always be placed before 1
non-default arguments in the function signature.
Reasoning(R): Placing default arguments before non-default arguments ensures that the
function can be called without specifying values for the default arguments if needed.

3
18 Assertion (A) : Fiber-optic cables are considered superior to twisted-pair cables for 1
high-speed data transmission.
Reasoning (R) : Fiber-optic cables use light signals to transmit data, which can travel
at higher speeds and over longer distances compared to the electrical signals used in
twisted-pair cables.
SECTION - B
19 i. Write the full form of 1+1=2
a. SMTP
b. PPP
ii. Mention the use of TELNET.
(OR)
i. Expand the following terms:
VOIP, TCP
ii. Mention one difference between PAN and LAN

20 Rao has written a code to input a number and check whether it is 2


prime or not. His code is having errors. Rewrite the correct code and
underline the corrections made.

21 Write a function count(CITIES) in Python, that takes the dictionary, CITIES as an 2


argument and displays the names (in uppercase)of the places whose names are longer
than 5 characters.
(OR)
Write a function, length(words), that takes a string as an argument and returns a list
containing length of each word of a string.
For example, if the words are “ Hello program", the list will have [5,7]
22 Predict the output of the Python code given below: 2

23 Write the Python statement for each of the following tasks using BUILT-IN 1+1=2
functions/methods only:
(i) To insert an element 400 at the fourth position, in the list L1.

4
(ii) To check whether a string named, message ends with a full stop / period or not.

24 Given two tables, 2


Student (Rollno, Admno, name, Class) and Fees (FeeID,Rollno,amount)
Develop an SQL query to combine two tables with the help of foreign key.
(OR)
Ruby is working in a database named CLIENT, in which she created a table named
“ORDER” containing columns Order_ID, Order_name, Amount, DOD. After creating
the table she notice that the customer name is not mentioned. So she decided to add a
new column “C_Name” of string datatype. She also decided that the category DOD is
not required and decided to delete. Help her to write the commands to complete the
task.
25 Predict the output of the following code 2

SECTION- C
26 Deduce the output of the following python code: 3

5
27 A vegetable store “Fresh Stock” maintains the inventory using a SQL table. The table is 3
given below for your view.

i. Name the columns that can be suitable as candidate keys.


ii. Perform insert query
ITEMCODE: 1007, ITEMNAME: GINGER and SCODE=15
iii. Write a query to add a column price into the existing table.
28 Write a function in Python to read a text file, sample.txt and displays those lines which 3
begins with a vowel’.
(OR)
Write a function,Count() in Python that counts and displays the number of words in the
text file named sample.txt.
29 Write the outputs of the SQL queries (i) to (iii) based on the relations Teacher and 3
Posting given below:

i. SELECT Name, Age, Department FROM Teacher WHERE Department


=”History” OR Gender =”F”;
ii. SELECT * FROM Teacher WHERE Age>=40;

6
iii. SELECT Name , Department, Salary WHERE Department NOT IN
Mathematics;
30 Mr. Ajay is a student in grade XII who is a budding programmer in Python. His teacher 3
assigns a task to him: accept a string from the user and create a user-defined function,
INSERT(), that inserts only the uppercase letters present in the string. He also wants to
display the inserted values. Help him by developing a code to perform the above tasks
using data structure.
SECTION- D
31 Write the output of the queries (i) to (iv) based on the table, TECH_COURSE given 1*4=4
below:

i) SELECT DISTINCT TID FROM TECH_COURSE;


(ii) SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY
TID HAVING COUNT(TID)>1;
(iii) SELECT CNAME FROM TECH_COURSE WHERE FEES>15000 ORDER BY
CNAME;
(iv) SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000
AND 17000;
32 Raju is a python programmer working in a leading software company in Chennai. He is 4
assigned with a task to provide the employee name for their annual appreciation with
incentive. For this he created a csv file named “incentive.csv” to store the names of the
employee in different criteria. The structure of the file is:
[Emp_id, Emp_Name, Emp_Designtion,No of Incentives received]
He needs to write a user defined functions that performs the following tasks
Accept() – to accept the details from the user and add it to the file.
Incentive() – to display the name of employee who received incentive more than 3 times.
The file “incentive.csv” should have a proper title.
SECTION - E
33 Granuda consultants are setting up a secured network for their office campus at 1*5=5
Faridabad for their day to day office and web based activities. They are planning to have
connectivity between 3 buildings and the head office situated in Kolkata. Answer the
Question (a) to (e) after going through the bulding poditions in the campus and the other
details which are given below:

7
Distance between the buildings:
• Building Ravi to Jamuna → 120 m
• Building Ravi to Ganga → 50 m
• Building Ganga to Jamuna → 65 m
• Faridabad campus to Head Office → 1460 km

Number of Computers:
• Building Ravi → 25 Nos.
• Building Jamuna → 150 Nos.
• Building Ganga → 51 Nos.
• Head Office → 10 Nos.

a) Suggest the most suitable place to house the server of this organization. Also
give a reason to justify your suggested location.
b) Suggest a cable layout of connections between the buildings inside the campus.
c) Suggest the placement of the following devices with justification:
• Switch
• Repeater
d) The organization is planning to provide a high speed link with its head office
situated in KOLKATA using a wired connection. Which of the following device
will be most suitable for this job?
i. Optical Fiber
ii. Co-axial cable
iii. Ethernet cable
e) The organization is planning to connect its Head office with Faridabad campus.
Which type of network out of LAN, MAN, or WAN will be formed? Justify
your answer.

34 i) Differentiate between “w” and “a” file modes in Python. 2+3


ii) Consider a file, CINEMA.DAT, containing records of the following structure:
[MovieName, Movie_ID, No_of_theatres]

8
Write a function, copy(), that reads contents from the file CINEMA.DAT and copies the
records with Movie name as “ KAALAI” to the file named CINEMA.DAT. The function
should return the total number of records copied to the file CINEMA.DAT.
(OR)
i) Differntiate seek() and tell() methods in python.
ii) A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where
MNO – Movie Number
MNAME – Movie Name
MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype as parameter and
displays all the records from the binary file CINEMA.DAT, that have the value of
Movie Type as mtype.
35 a) Write the output of the code given below: 2+3
def printMe(q,r=2):
p=r+q**3
print(p)
#main-code
a=10
b=5
printMe(a,b)
printMe(r=4,q=2)

b) The code given below inserts the following record in the table Student:
Rollno- integer
Name-Varcahr(30)
Class- integer
Marks- Integer

Note the following to establish connectivity between Python and MySQL:


* Username is root
* Password is toor@123
* The table exists in a “stud” database.
* The details (RollNo, Name, Clas and Marks) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Student.
Statement 3 - to add the record permanently in the database
import mysql.connector as mysql
def sqlData():
con1=mysql.connect(host="localhost",user="root", password="toor@123",
database="stud")
mycursor = ________________ #Statement 1
rno=int(input("Enter Roll Number :: "))
name=input("Enter name :: ")

9
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)

a) Predict the output of the code given below:

b) The code given below inserts the following record in the table Student:
Rollno- integer
Name-Varcahr(30)
Class- integer
Marks- Integer
Note the following to establish connectivity between Python and MySQL:
* Username is root
* Password is toor@123
* The table exists in a “stud” database.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those students whose marks
are greater than 90.
Statement 3- to read the complete result of the query (records whose marks are greater
than 90) into the object named data, from the table student in the database.

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="root",password="toor@123",
database="stud")
mycursor=_______________ #Statement 1
print("Students with marks greater than 90 are : ")

10
______________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()

11
Sample Paper 32
Computer Science (083)
CLASS XII 2023-24

Date: Max. Marks: 70


Subject: Computer Science (083) Time: 3 Hours

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each. Three internal choice is
given in Q19, Q21 and Q24
5. Section C has 05 Short Answer type questions carrying 03 marks each. One internal choice is given in
Q28
6. Section D has 02 Long Answer type questions carrying 04 marks each.
7. Section E has 03 questions carrying 05 marks each. Two internal choice is given in Q34 and Q35.
8. All programming questions are to be answered using Python Language only.

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

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

1
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 1
in file?
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 1
following code?

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 1
out of the 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
2
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 State True or False: 1
A try block in Python must always be followed by an except block.
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, 1
regardless of 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 1
connect() function is 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 1
arguments accepted by the function
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 1
of fields, separated by commas or some other delimiter.
Reason (R): writerow() function can be used for writing into writer object.
SECTION – B

19 Write two points of difference between Switch and Router. 2


(OR)
Write two points of difference between Web Server and Web Browser.
20 Raman has written a code to find its sum of digits of a given number passed 2
as parameter to function sumdigits(n). His code has errors. Rewrite the
correct code and underline the corrections made.
def sumdigits(n):
d=0
for x in

3
str(n):
d=d+x
return d
n=int(input(‘Enter any number”))
s=sumdigits(n)
print(“Sum of digits”,s)
21 Write a function sumcube(L) to test if an element from list L is equal to the sum of 2
the cubes of its digits i.e. it is an "Armstrong number". Print such numbers in the
list.
Example:
If L contains [67,153,311,96,370,405,371,955,407]
The function should print 153,370,371,407

(OR)
Write a function called letter_freq(my_list) that takes one parameter, a list of
strings(mylist) and returns a dictionary where the keys are the letters from mylist
and the values are the number of times that letter appears in the mylist,
Example:
If the passed list is as: wlist=list("aaaaabbbbcccdde")
then it should return a dictionary as{“a”:5,”b”:4,‟c‟:3,‟d‟:2,‟e‟:1}
22 Predict the output of the following code: 2

23 Explain the use of ‘Primary Key’ in a Relational Database Management System. 2


Give example to support your answer.
24 Differentiate between char and varchar in SQL with appropriate examples. 2
(OR)
What are different types of SQL Aggregate Functions? Give two examples.
25 Predict the output of following code: 2

SECTION – C

4
26 Deduce the output of the following python code: 3

27 A vegetable store “Fresh Stock” maintains the inventory using a SQL table. The table
is given below for your view.

I. Name the column that can be suitable as a primary key. Justify.


II. Write a query to delete a column QTY from the above table.
III. Write a query to add a column price and by default the price should be 20.
28 Write a function countwords() in Python that counts the number of words 3
containing digits in it present in a text file “myfile.txt”.
Example: If the “myfile.txt” contents are as follows:
This is my 1st class on Computer Science. There are 100 years in a Century.
Student1 is present in the front of the line.
The output of the function should be: 3
(or)
Write a function countwords() in Python, which should count the occurrences of
word ‘me’ and ‘my’ in the text file ‘myfile.txt’.
Example: If the “myfile.txt” contents are as follows:
“I will have nothing more to do with you and you are no longer my friend, no
longer my 'faithful slave,' as you call yourself!
Keep the third piece of wisdom for your own use, and let me have the gold.” The
output of the function should be: No of words ‘my’ is 2
No. of Words ‘me’ is 1

5
29 Consider the table “Employee” given below:

Based on the given table, write SQL queries for the following:
i. Increase the salary by 10% whose salary is less than 3500.
ii. Display the Ename, DeptID, Dname and Salary as “Gross Salary” of all
Employee whose location is New Delhi.
iii. Delete the record of the employee whose DeptID is 1.
30 A list contains following record of a student: [Rno, Name, Dob, Class] 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 Consider the tables STUDENT and Stream given below: 1*4=
4

6
Write SQL queries for the following:
i. Display Admission no and Stream ID from the tables STUDENT and
STREAM.
ii. Display the structure of the table STUDENT
iii. Display all the details from the table STUDENT whose class is XII.
iv. Display the name of the student whose name ends with ‘n’ and they belong
to grade XII.
32 Ranjan Kumar of class 12 is writing a program to create a CSV file “user.csv”
which will 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.

i. Name the module he should import in Line 1.


ii. In which mode, Ranjan should open the file to add data into the file.
iii. Fill in the blank in Line 3 to read the data from a CSV file.
iv. Fill in the blank in Line 4 to close the file.

SECTION - E
33 Teach and Learn is leading software developing company resides in Chennai as it 1*5
head office. They have four major blocks administrative office, developing block,
finance block and reception block. Their distance between the blocks is provided.

7
Shortest distance between the blocks

No of computers
• Developing block → 50
• Finance block → 70
• Administrative Office → 120
• Reception → 40

Answer the following based on the above details:

i. Suggest the most suitable location to install the main server and justify.
ii. Suggest the best cable layout for the effective network connectivity which
connects all the blocks with the server.
iii. Suggest the device to be installed in each building:
a. Modem, b. Switch
iv. The company is planning to connect with the external organization which is
located in New York, which type of network will be formed.
v. The company often communicate with video call for different reasons with
their clients at abroad. Which type of protocol is used of the above situation.

34 i. Differentiate the method read() and readlines(). 2+3


ii. Keshav is a student in CBSE school. He is assigned with a project to work on
binary file operations. Help him to accomplish the below task.
o addrecord() to create a binary file called “Student.DAT” containing
information of the student in form of list datatype.
Information to be collected Rollno, name, marks(out of 100) of each
student.
o search() to display the name and marks based on the Rollno.

(OR)

i. How text files are different from binary files.


ii. Mr. Mathew is a programmer who has recently joined the company and given
a task to write a python code to perform update operations in binary
file(Emp.dat) which contains (EmpID, Ename and Salary). Help him to
perform the below task.
8
• Addvalue() to create a binary file called “Emp.dat”and inserts the above
value as user input.
• Updatvalue() – update the salary of the employee by 2000 Rs whose
emp no is 23.

35 i. Give one point of difference between primary key and unique key. 2+3
ii. Write the following missing statements to complete the code:

Statement 1 – To open/activate the school database.


Statement 2 – To execute the command that updates the record in the table
Student.
Statement 3- To make the update in the database permanently.
Statement 4 – To terminate the connection.

(OR)

i. Give one point of difference between char(n) and varchar(n).


ii. Write the following missing statements to complete the code:

Statement 1 – To create cursor object to execute the query.


Statement 2 – To execute the query stored in the variable change.
Statement 3 – To make the changes in the database physically.
Statement 4 – which method is used to store the data in the results.

You might also like