10 set of computer science
10 set of computer science
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
9. In files, there is a key associated with each record which is used to differentiate among different records. For every
file, there is atleast one set of keys that is unique. Such a key is called
(a) unique key (b) prime attribute
(c) index key (d) primary key
10. a = 1.0
b = 1.0
a is b # Line 1
Output of Line 1 will be
(a) False (b) True
(c) 1.0 (d) 0.0
11. Which of the following is a correct syntax to add a column in SQL command?
(a) ALTER TABLE table_name ADD column_name data_type;
(b) ALTER TABLE ADD column_name data_type;
(c) ALTER table_name ADD column_name data_type;
(d) None of the above
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’>
Directions : (Q.Nos.-17 and 18) are Assertion and Reason based Questions.
17. Assertion (A) Built-in functions are predefined in the system and can be directly used in any program.
Reason (R) id( ) and type( ) are built-in functions in Python.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
18. Assertion (A) The CSV files are like TEXT files and are comma separated value files.
Reason (R) The data stored in CSV files are separated by comma by default. Although the delimiter can be changed.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
Section - B
19. Riya was asked to accept a list of even numbers ,but she did not put the relevant condition while accepting the list
of numbers. She wrote a user defined function odd to even (L) that accepts the list L as an argument and converts
all the odd numbers into even by multiplying them by 2.
def oddtoeven (L)
for i in range (size(L)):
if (L[i]%2! == 0)
L[i]= L[1] ** 2
print (L)
There are some errors in the code . Rewrite the correct code.
Section-C
TABLE: STREAM
STRCDE STRNAME
Page 5 Computer Science Class 12
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
Page 6 Computer Science Class 12
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
Page 7 Computer Science Class 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
Page 8 Computer Science Class 12
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
Page 10 Computer Science Class 12
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 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.
Page 3 Computer Science Class 12
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:
Page 5 Computer Science Class 12
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:
X to Z 40 m
Z to Y 60 m
Y to X 135 m
X to U 70 m
Z to U 165 m
Z to U 80 m
Number of computers in each of the offices is as follows:
X 50
Z 130
Y 40
U 15
(i) Suggest a suitable cable layout of connectivity of the offices.
(ii) Suggest placement of server in the network with suitable reason.
(iii) Suggest placement of following devices in the network:
(a) Switch/Hub
(b) Repeater
(iv) Suggest a suitable topology for connecting the computers in each building.
(v) Write any one advantage of the topology suggested.
32. (a) Carefully observe the following Python code and answer the question that follow:
x = 5
def func2():
x = 3
global x
x = x + 1
print(x)
print(x)
On execution the above code, produces the following output:
6
3
Explain the output with respect to the scope of the variables.
(b) Write the code to create a table Product in database Inventory with following fields
Fields Datatype
PID varchar(5)
PName char(30)
Price float
Rank varchar(2)
Note the following to establish the connection between Python and MySQL:
Host : localhost
Username : system
Password : hello
Database : Inventory
o
Page 7 Computer Science Class 12
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.
Page 8 Computer Science Class 12
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 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
Page 3 Computer Science Class 12
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
Page 4 Computer Science Class 12
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
Page 5 Computer Science Class 12
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
Page 6 Computer Science Class 12
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)
Page 7 Computer Science Class 12
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
Page 10 Computer Science Class 12
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 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
Page 2 Computer Science Class 12
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.
Page 3 Computer Science Class 12
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])
Section C
26. (a) Consider the tables Student and House given below. What will be the output of the statement given?
Table: Student
Rno Sname Class Hcode
1 Raj 12ScA C1
2 Shekhar 11ComC C2
3 Ravi 12HumB C2
4 Jaisnav 12ScB C3
Table: House
Hcode Lname
C1 East
C2 West
C3 South
C4 North
SELECT S.Sname , H.Lname FROM Student S, House H WHERE S.Hcode = H.Hcode AND
SName LIKE “R%”;
(b) Consider the following table STORE and answer the questions
TABLE: STORE
ItemNo Item Scode Qty Rate LastBuy
2005 Sharpener Classic 23 60 8 31-JUN-09
2003 Balls 22 50 25 01-FEB-10
2002 Gel Pen Premium 21 150 12 24-FEB-10
2006 Gel Pen Classic 21 250 20 11-MAR-09
2001 Eraser Small 22 220 6 19-JAN-09
2004 Eraser Big 22 110 8 02-DEC-09
2009 Ball Pen 0.5 21 180 18 03-NOV-09
Write SQL commands for the following statements:
(i) To display details of all the items in the STORE table in ascending order of LastBuy.
(ii) To display ItemNo and Item name of those items from STORE table, whose Rate is more than `15.
(iii) To display the details of those items whose Supplier code (Scode) is 22 or Quantity in Store (Qty) is more than
110 from the table STORE.
(iv) To display minimum rate of items for each Supplier individually as per Scode from the table STORE.
27. Write a program to accept a filename and a position. Using the inputs, call a function SearchFile(Fname, pos) to
read the contents of the file from the position to the end. Now, display all those words that start with “U” or “u”.
o
Write a program to search a Employee record according to Id from the “emp.txt” file. The “emp.txt” file contains
Id, Name and Salary fields. Assume that first field of the employee records (between Id and Name) is separated with
a comma(,).
Page 5 Computer Science Class 12
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)
Page 6 Computer Science Class 12
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.
Page 7 Computer Science Class 12
Section E
34. Consider the following table Student:
Table : Student
AdmNo RollNo Name Class Marks
2715 1 Ram 12 90
Page 8 Computer Science Class 12
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 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
17. Assertion (A) In a cross join the number of records in the output will be the maximum.
Reason (R) A cross join is also called a Cartesian product.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
18. Assertion (A) A file that is opened using the open() function may not specify the mode of opening it.
Reason (R) If the mode is not specified , the read mode is used by default..
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
Section B
19. Observe the given list and find the answer of questions that follows.
list1 = [23, 45, 63, ‘Hello’, 20
‘World’, 15, 18]
(i) list1[–3] (ii) list1[3]
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
Page 5 Computer Science Class 12
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)
Page 6 Computer Science Class 12
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.
(b) Write the code to create the following table Student with the following fields
RollNo FirstName LastName Address ContactNo
ContactNo Marks Course Rank
In the table, Rank should be Good, Best, Bad, Worst, Average.
o
(a) Differentiate between a logical error and syntax error. Also, give suitable examples of each in Python.
(b) What is the use of fetchone() method? Write an example code to fetch a single record from a database.
Note :
Database : PythonDB
Table : Student
Host : localhost
UsedlD : root
Password : arihant
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?
Page 8 Computer Science Class 12
(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 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]
8. The constraint that ensures that the field does not get any NULL values is
(a) NULL (b) PRIMARY KEY
(c) CHECK (d) NOT NULL
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.
Page 3 Computer Science Class 12
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)))
SECTION C
26. Consider the tables Hotel and Room given below :
Table : Hotel
TId CName Roomld DtofArrival Charges
T1 Ritesh R1 2016-09-09 1800
T2 Sumana R2 2020-08-01 2000
T3 Abhi R3 1995-04-05 3000
T4 Ram R1 1994-02-02 2500
T5 Nitin R2 NULL 7000
Table : Room
RoomlD RoomType FLoor
R1 AC First
R2 Deluxe Second
R3 General Second
(a) Write a command to display the customer names and the types of rooms in which they are staying.
(b) With respect to the tables given above, write SQL commands for the following.
(i) Create the table hotel and insert the 1st record
(ii) Display the details of customers who have arrived after 01-05-2005
(iii) Display names and room types of customers whose charges are between 2000 and 3000.
(iv) Display Names of customers who are staying in “AC” rooms”
27. A binary file “data.dat” contains records of students as per following structure :
Ano Sname Marks
1 Raj 850
h
h
Write a Program in Python to search for a student whose number/id is input by the user. If not found appropriate
message should be displayed.
o
Write a program with method countand ( ) to count the word ‘and’ or And’ as an independent word in a text file
“status.txt”. e.g. if the content of the file “status. txt” is as follows:
Welcome to your one-step solutions for all your study, practice and assessment needs for various competitive &
recruitment examinations and school segment. We have been working tirelessly for over a decade to make sure that
you have best in class study resources because you deserve SUCCESS AND NOTHING LESS...
Then the output of the program should be: Count of _and_ in file is/are: 3
Page 5 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:
Page 6 Computer Science Class 12
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?
(a) addToy() : To append data of toys and store them to the file “Toys.csv” only if the Toy category is “Boys”.
Also display the number of toys added.
(b) showToys() : To open the file “Toys.csv” and display records of toys whose cost is above 1000.
Section E
34. Consider the following table Cab :
Table : Cab
CablD CabType Nop Rate
Cb1 Sedan 4 40
Cb2 Yellow Taxi 5 25
Cb3 Mini 3 30
Cb4 Micro 2 20
(i) Which column qualifies to be the primary key?
(ii) Write a command to display the fields of the table along with their types and sizes.
(iii) Write statements to :
(a) Add a new column Driver varchar(30)
(b) Change data type of Rate column to float(6,1).
(Option for part (iii) only)
(a) To display the cab type whose rate is more than 25.
(b) To display cab id and Number of passengers for cab sedan.
35. Riya wrote a program to search any string in text file “school”. Help her to execute the program successfully.
def check () :
datafile = open (.....)
found = input (“Enter any string to
be searched : ”)
f = False
for line in ....... :
if found in line :
f = .......
break
return f
f = check ()
if (f = =.......) :
print (“True”)
else :
print (......)
(i) Riya should open which file to search any string?
(ii) Which value will assign to f in Line 7?
(iii) Fill the blank in Line 5.
EN
Page 1 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.
Page 5 Computer Science Class 12
(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
Page 6 Computer Science Class 12
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)
Section D
31. Tech Up Corporation (TUC) is a professional consultancy company. The company is planning to set up their new
offices in. India with its hub at Hyderabad. As a network adviser, you have to understand their requirement and
suggest to them the best available solutions. Their queries are mentioned as (i) to (v) below.
Physical locations of the blocks of TUC
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
Page 8 Computer Science Class 12
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
Page 9 Computer Science Class 12
(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 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.
Page 3 Computer Science Class 12
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?
Keys Values
A One
B Two
C Three
D Four
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”.
Page 5 Computer Science Class 12
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
Page 6 Computer Science Class 12
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.
(iv) Suggest the most suitable media to provide secure, fast and reliable data connectivity between Delhi Head
Office and the Bengaluru Office Setup.
(v) Expand the following
WAN
LAN
32. (a) Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between
200 and 300 (both included).
(b) Consider the table Faculty whose columns’ name are
F_ID, Fname, Lname, Hire_date,
Salary, Course_name
Write the code to insert the following record into the above table.
101 Riya Sharma 12-10-2004 35000 Java Advance
102 Kiyaan Mishra 3-12-2010 28000 Data Structure
o
(a) Which of the following are invalid, names and why?
(i) PaidInterest (ii) S-num
(iii) Percent (iv) 123
(b) What is the utility of fetchall() method? Write a code to fetch all the records of a Student table from PythonDB
Database.
Note :
Host : localhost
Database : PythonDB
User : root
Password:arihant
Table : Student
Section E
34. Consider the following table
TABLE : PATIENTS
No Name Age Department Dateofadm Charges Sex
1 Ketaki 16 ENT 24/02/98 300 F
2 Ankita 29 Cardiology 20/02/98 800 F
3 Zareen 45 Gynaecology 22/02/98 300 F
4 Kush 19 Cardiology 13/01/98 800 M
5 Shailya 31 Nuclear Medicine 19/02/98 400 M
(i) What would be the width of Dateofadm field?
(ii) Write commands to remove the records of “Cardiology” department.
(iii) Write statements to :
(a) Display a report showing Name, charges and discount (15%) for all patients.
(b) Display names of female patients .
(option for part (iii) only)
o
(a) Which function will find the total charges of all patients?
(b) Name the constraint that will restrict duplicate values in Name column.
35. A user defined method to open a text file “para.txt” and display count of number of ‘c’ or ‘C’ and number of ‘e’ or
‘E’ separately.
def test():
f=open(“Para.TXT”)
n1=0
n2=0
while True:
1=........... //Statement
if not 1:
break
for i in 1:
if (i ==‘E’ or i ==‘e’):
n1=n1+1
elif(i==‘C’ or i==‘c’):
n2=n2+1
print(n1)
print(n2)
f.close()
(a) Which module needs to be imported to use text file handling functions?
(b) Write the functionname to close a file object.
(c) Write the code best suitable for statement as marked.
EN
Page 1 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
Page 2 Computer Science Class 12
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.
Page 3 Computer Science Class 12
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
Page 5 Computer Science Class 12
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,+,+,*
Page 6 Computer Science Class 12
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.
Page 7 Computer Science Class 12
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
35. A user-defined method to open a text file “para.txt” and write its contents to another file fter removing the 3rd line
def Func():
with open (‘Para.txt’, ‘r’) as f:
l=f.readlines()
f.close()
print(l)
del l[3]
print(l)
f=open (‘Para.txt’, ‘w’)
f...........
f.close()
(a) Which module needs to be imported to use operating system functions like rename() and remove().
(b) Write the function name to open a text file.
(c) Fill the blank as marked in above code.
EN
Page 1 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
18. Assertion (A) Python supports addition of data in file , preserving the previous data.
Reason (R) The write mode erases all previous data of a pre-existing file.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
Section B
19. Write the corresponding Python expression for the following mathematical expression.
(i) z= a/a+ b – d2
(ii) z= x2 + y3
20. Mr. GopiNath Associate Manager of Unit. Nations corporate recently discovered that the communication between
his company’s accounts office and HR office is extremely slow and signals drop quite frequently. These offices are
120 metre away from each other and connected by an Ethernet cable.
(i) Suggest him a device which can be installed in between the office for smooth communication.
(ii) What type of network is formed by having this kind of connectivity out of LAN, MAN and WAN?
o
Define hub and write its functions and types.
21. (a) Determine which of the following identifiers are valid. If invalid, explain with reason.
(i) name_1 (ii) _SUM
(iii) $Sum (iv) num ^ 2
(b) Find the output of the following code
i=1
while (i<5):
print(i)
i=i*2
22. Differentiate between char(n) and varchar(n) data types with respect to databases.
23. (a) Mention any two advantages of E-mail over conventional, mail.
(b) Mr. Lal owns a factory which manufactures automobile spare parts. Suggest him the advantages of having a
web page for his factory
Find the syntax error in the following program and underline after correct them.
90 = w
while(w > 60)
print(w)
w = w – 50
Section C
26. Consider the tables FAMILY and Occupation:
TABLE FAMILY
No Name Female Members Male Members Income Occup-ationId
1 Mishra 3 2 7000 O1
2 Gupta 4 1 50000 O2
3 Khan 6 3 8000 O2
4 Chaddha 2 2 25000 O1
5 Yadav 7 2 20000 O3
6 Joshi 3 2 14000 O2
7 Maurya 6 3 5000 O1
8 Rao 5 2 10000 O3
Table : OCCUPATION
Occupationld Type
O1 Service
O2 Business
O3 Mixed
(a) To display Family name , corresponding occupation and income where male members are more than 2.
(b) Write SQL queries for statements (i) to (iv) based on tables FAMILY and Occupation.
(i) To select all the information of family, whose Occupation is Service.
(ii) To list the name of family, where female members are more than 3.
(iii) To list all names of family with income in ascending order.
(iv) To count the number of family, whose income is less than 10000.
27. Write a method countFile() to count and display the number of lines starting with the word ‘FILE’ (including small
cases and upper cases) present in a text file “start.txt”.
e.g. If the file “start.txt” contains the following lines:
Get the data value to be deleted,
Open the file for reading from it.
Read the complete file into a list
Delete the data from the list
Open the file
Open same file for writing into it
Write the modified list into file.
Close the file.
The method should display
Total lines started with word ‘FILE’ is/are: 0
o
Write definition of a function that takes input a sentence and display the list of words that end with a lowercase
vowel and list of words that end with a lowercase consonant
Page 5 Computer Science Class 12
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, +, +, *)
Page 6 Computer Science Class 12
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.
Page 7 Computer Science Class 12
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.
Section E
34. Consider the following table FLIGHTS :
TABLE : FLIGHTS
FL_NO STARTING ENDING NO_FLIGHT NO_
STOPS
IC301 MUMBAI DELHI 8 0
IC799 BENGALURU DELHI 2 1
MC101 INDORE MUMBAI 3 0
IC302 DELHI MUMBAI 8 0
AB812 KANPUR BENGALURU 3 1
IC899 MUMBAI KOCHI 1 4
AM501 DELHI TRIVANDRUM 1 5
MU499 MUMBAI MADRAS 3 3
IC701 DELHI AHMEDABAD 4 0
(i) The command to create the table was written as :
Create table FLIGHTS( FL_NO integer, STARTING char(20), ENDING char(30), NO_FLIGHT integer, NO_
STOPS integer);
What is wrong with command ?
(ii) What is the cardinality of the table ?
(iii) Which functions will be used to :
(a) Display total number of flights .
(b) Display number of flights whose FL_NO starts with “IC”
(option for part (iii) only)
Write function names to :
(a) Show the average Number of stops.
(b) Show the maximum number of stops.
35. A user-defined method to open a text file ‘Author.txt” and display the lines that have even number of words.
def evenwords():
f=open(“Author.txt”)
ln=f.readlines()
for line in ln:
linex=............// Statement
if len(linex)%2==0:
print(line)
f.close()
(a) How is readline() method different from readlines() method in Python?
(b) Write the use of the reader object in csv file operations.
(c) Fill the blank as marked statement.
EN