Class 12 CS 32 Sets QP Combined Papers
Class 12 CS 32 Sets QP Combined Papers
Class 12 CS 32 Sets QP Combined Papers
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
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
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
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’>
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.
Section-C
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
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 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.
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
4. You can repeat the elements of the tuple using which operator?
(a) * (b) +
(c) ** (d) %
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
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]
14. A file can be opened both for reading and writing using............mode.
(a) r (b) r+
(c) a (d) None of these
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
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:
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
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
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
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
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
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)
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.
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
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
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
(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.
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”
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]
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”.
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
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*
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)
22. What do you understand by primary key? Give a suitable example of primary key from a table containing some
meaningful data.
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])
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?
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) /
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
12. The_____clause with the COUNT() function counts only the unique values in an attribute.
(a) UNIQUE (b) HAVING
(c) DISTINCT (d) LIKE
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
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]
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.
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]
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
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+
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)))
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?
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
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()
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.
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)
Section C
26. (a) Consider the following tables PERSON and ORDERS
Table : PERSON
P_Id Last_Name First_Name City
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
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
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)
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
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
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
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
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) %
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( )
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?
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
Table : SALGRADE
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.
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
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
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
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
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?
22. Define UPDATE command of SQL with its basic syntax and also give one of its example.
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
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.
Section E
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
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
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
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
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
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
Find the syntax error in the following program and underline after correct them.
90 = w
while(w > 60)
print(w)
w = w – 50
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:
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
Write Python code to display the names of those traders who are either from Delhi or from Mumbai.
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
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.
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
b) Write output of the queries (i) to (iv) based on the table Sportsclub
Table Name: Sportsclub
playerid pname sports country rating salary
5|Page
10007 PAUL SNOOKER USA B 10000
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
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)
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
_________________ #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} )
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
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
(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:
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”)
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()))
Table: Item
SCode IPRICE ICity
S01 1200 Delhi
S02 2500 Mumbai
S01 3200 Maharashtra
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.
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”]
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.
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:
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.
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:
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
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:
######################
10 | P a g e
Sample Paper 14
Computer Science (083)
CLASS XII 2023-24
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
3 If Statement in Python is __ 1
(a) looping statement (b) selection statement (c) iterative (d) sequential
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]
if not False:
print(10)
else:
print(20)
Page 1 of 9
(a) 10 (b) 20 (c) True (d) False
(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
10 Identify the device on the network which is responsible for forwarding data from one device to 1
another
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?
14 Which of the following clause is used to remove the duplicating rows from a select statement? 1
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;‐
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:
21 What do you mean by Foreign key? How it is related with Referential Integrity? 2
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?
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
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.
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.
FINANCE BLOCK
(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?
The Following program code is used to increase the salary of Trainer SUNAINA by 2000.
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)
The Following program code is used to view the details of the graduate whose subject is
PHYSICS.
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()
Page 9 of 9
Sample Paper 15
Computer Science (083)
CLASS XII 2023-24
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
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
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;
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
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?
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}
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?
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
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
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
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
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
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
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.
It rained yesterday.
It might rain today.
I wish it rains tomorrow too.
I love Rain.
.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:
(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:
(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
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:
(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
a) 2 + 3 == 4 +5 ==7 b) 0 ==1 == 2
a) 2**3**2 b) (2**3)**2
num1 = num1 *3
print(num1)
6. Which of the following is used toread n characters from afile object“ f1” . 1
print(S) #Statement2
(a) Primary Key (b) Foreign Key (c) CandidateKey (d) AlternateKey
11. Which of the following statements correctly explain the function of seek() method? 1
12. What is break statement in the context of flowof control in the python programming. 1
>>>L1=[8,11,20]
>>>L1*3
(b) BothA and Raretrue and Ris not thecorrect explanation for A
SECTIONB
30=n
fori in range(0,n)
IF i%4==0:
print (i*4)
Else:
print (i+4)
OR
D1['age'] =27
D1['address'] = "Delhi"
print(D1.items())
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=” #“ )
OR
def my_func(var1=100,var2=200):
var1+=10
return var1+var2
print(my_func(50),my_func())
OR
(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
CITYNAME CHAR(30)
SIZE INTEGER(3)
AVGTEMP INTEGER
POLLUTIONRATE INTEGER
POPULATION INTEGER
Couldn'tputHumpty togetheragain
OR
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.
OR
SECTIOND
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.
(iv) Thecompany is planning to link itshead office situated in New Delhi with the
offices in hilly areas. Suggest a way to connect iteconomically.
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="#")
OR
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)
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.
OR
Writea Program inPython thatdefines and calls the following user defined functions:
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
Table: Posting
1 History Agra
2 Mathematics Raipur
3 ComputerScience Delhi
c)To add foreign key to newly created column P_ID in TeacherTable assuming that
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
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:
else:
fin.close()
fout.close()
(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.
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
For example:
If L contains [9,4,0,3,11,56]
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
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()
(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)
************************
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:
No of Computers
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.
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
SECTION A
(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+
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
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:
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;
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
(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:
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
(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
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
SECTION A
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.
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( ____________ )
Page 2 of 14
13. Name any two protocols used for video conferencing. 1
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
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”)
22. What is the difference between Equi join and Natural join? Give an Example 2
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
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
DEPARTMENT
DEPT_ID D_NAME
101 Production
102 Sales
103 Marketing
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]
● 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
Block Computers
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.
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")
“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
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?
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 $@
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
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
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.
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.
SECTION C
27 Consider the table itemmast below, write the output of the MySQL Queries.
3
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
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
Table: CUSTOMER
C_ID CustomerName City I_ID
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
Development to Admin 28 m
Admin to Training 32 m
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.
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?
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 $@
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):
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.
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.
SECTION C
27 Write the output of the queries (i) to (iii) based on the table, TEACHER given below:
TEACHER 3
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
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
Table: RECIPIENT
RecId SenderId RecName RecAddress RecCity
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
Engineering 75
Media 12
Business 40
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
SECTION-A
1. Name the Python library module needed to be imported to invoke 1
following functions:
a. floor ( )
b. randomint ( )
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
1
10. Fill in the blank: 1
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’)
(a) HAVING
(b) WHERE
(c) IN
(d) BETWEEN
func( )
func( 2,3)
OR
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
(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
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:
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. ()
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()
(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
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
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
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.
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
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.
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
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.
11
Sample Paper 26
Computer Science (083)
CLASS XII 2023-24
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
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]
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
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
OR
def CALLME(n1=1,n2=2):
n1=n1*n2
n2+=2
print(n1,n2)
CALLME()
CALLME(3)
OR
mylist = [2,14,54,22,17]
tup = tuple(mylist)
for i in tup:
print(i%3, end=",")
OR
Section-C
26 a. Consider the following tables Trainer and Course: 1+2
b. Write the Outputs of the MySQL queries (i) to (iv) based on the given above tables:
i. SELECT DISTINCT(CITY) FROM TRAINER WHERE SALARY>80000;
ii. SELECT TID, COUNT(*), MAX(FEES) FROM COURSE GROUP BY TID
HAVING COUNT(*)>1;
iii. SELECT T.TNAME, C.CNAME FROM TRAINER T, COURSE C WHERE
T.TID=C.TID AND T.FEES<10000;
iv. SELECT COUNT(CITY),CITY FROM TRAINER GROUP BY CITY;
27 Write a method/function COUNTLINES_ET() in python to read lines from a text file 3
REPORT.TXT, and COUNT those lines which are starting either with ‘E’ or starting
with ‘T’ and display the Total count separately.
For example:
If REPORT.TXT consists of
“ENTRY LEVEL OF PROGRAMMING CAN BE LEARNED FROM PYTHON. ALSO, IT
IS VERY FLEXIBLE LANGUGAE. THIS WILL BE USEFUL FOR VARIETY OF
USERS.”
Then, Output will be:
No. of Lines with E: 1
No. of Lines with T: 1
OR
Write a method/ function SHOW_TODO() in python to read contents from a text file
ABC.TXT and display those lines which have occurrence of the word ‘‘TO’’ or
‘‘DO’’.
For example :
If the content of the file is
“THIS IS IMPORTANT TO NOTE THAT
SUCCESS IS THE RESULT OF HARD WORK.
WE ALL ARE EXPECTED TO DO HARD WORK.
AFTER ALL EXPERIENCE COMES FROM HARDWORK.”
OR
i. Suggest the most suitable location to install the main server of this institution
to get efficient connectivity.
ii. Suggest by drawing the best cable layout for effective network connectivity
of the blocks having server with all the other blocks.
iii. Suggest the devices to be installed in each of these buildings for connecting
computers installed within the building out of the following:
Modem, Switch, Gateway, Router
iv. Suggest the most suitable wired medium for efficiently connecting each
computer installed in every building out of the following network cables:
Coaxial Cable, Ethernet Cable, Single Pair, Telephone Cable
v. Suggest the type of network implemented here.
32 (a) Write the output of following python code: 2+3
def result(s):
n = len(s)
m=''
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m + s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '#'
print(m)
result('Cricket')
(b) Avni is trying to connect Python with MySQL for her project. Help her to write the
python statement on the following:
i. Name the library, which should be imported to connect MySQL with Python.
ii. Name the function, used to run SQL query in Python.
iii. Write Python statement of connect function having the arguments values as :
Host name :192.168.11.111
User : root
Password: Admin
Database : MYPROJECT
OR
(a) Find the output
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print(Msg3)
b) Your friend Jagdish is writing a code to fetch data from a database Shop and table
name Products using Python. He has written incomplete code. You have to help him
write complete code:
import __________ as m # Statement-1
object1 = m.connect(
host="localhost",
user="root",
password="root",
database="Shop"
)
object2 = object1._____ # Statement-2
query = '''SELECT * FROM Products WHERE NAME LIKE "A%";'''
object2._____(query) # Statement-3
object1.close()
33 What is the advantage of using pickle module? 2+3
Write a program to write into a CSV file “one.csv” Rollno, Name and Marks separated
by comma. It should have header row and then take input from the user for all following
rows. The format of the file should be as shown if user enters 2 records.
Roll.No,Name,Marks
20,Ronit,67
56,Nihir,69
OR
What is difference between tell() and seek() methods?
Write a program to read all content of “student.csv” and display records of only those
students who scored more than 80 marks. Records stored in students is in format :
[Rollno, Name, Marks]
34 ABC Gym has created a table TRAINER. Observe the table given below and answer the 1+1
following questions accordingly. +2
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
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
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]
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
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
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
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.
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
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
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
110
(b) Write SQL command to delete a table from database.
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’)
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
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
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()
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
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
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.
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.
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:
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.
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
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)
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.
10
______________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()
11
Sample Paper 32
Computer Science (083)
CLASS XII 2023-24
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
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
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.
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.
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
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.
(OR)
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: