Sample Questions Set
Sample Questions Set
Q.22 Which one of the following is the default extension of a Python file?
a. .exe
b. .p++
c. .py
d. .p
Q.23 Which of the following symbol is used in Python for single line comment?
a. /
b. /*
c. //
d. #
Q.24 Which of the following statement opens a binary file record.bin in write mode and writes
data from a list lst1 = [1,2,3,4] on the binary file?
a. with open('record.bin','wb') as myfile:
pickle.dump(lst1,myfile)
b. with open('record.bin','wb') as myfile:
pickle.dump(myfile,lst1)
c. with open('record.bin','wb+') as myfile:
pickle.dump(myfile,lst1)
d. with open('record.bin','ab') as myfile:
pickle.dump(myfile,lst1)
Q.25 Which of these about a dictionary is false?
a) The values of a dictionary can be accessed using keys
b) The keys of a dictionary can be accessed using values
c) Dictionaries aren’t ordered
d) Dictionaries are mutable
Q.26 What is the output of following code:
T=(100)
print(T*2)
a. Syntax error
b. (200,)
c. 200
d. (100,100)
Q.35 Evaluate the following expression and identify the correct answer.
16 - (4 + 2) * 5 + 2**3 * 4
a. 54
b. 46
c. 18
d. 32
Q.36 What will be the output of the following code?
def my_func(var1=100, var2=200):
var1+=10
var2 = var2 - 10
return var1+var2
print(my_func(50),my_func())
a. 100 200
b. 150 300
c. 250 75
d. 250 300
Q.37 What will be the output of the following code?
value = 50
def display(N):
global value
value = 25
if N%7==0:
value = value + N
else:
value = value - N
print(value, end="#")
display(20)
print(value)
a. 50#50
b. 50#5
c. 50#30
d. 5#50#
Q.94 Find and write the output of the following Python code:
def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('Fun@Python3.0')
Q.95 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]
Q.96 Write a function in Python that counts the number of “Me” or “My” words
present in a text file “STORY.TXT”.
If the “STORY.TXT” contents are as follows:
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:
Count of Me/My in file: ?
OR
Write a function AMCount() in Python, which should read each character
of a text file STORY.TXT, should count and display the occurance of
alphabets A and M (including small cases a and m too).
Example:
If the file content is as follows:
Updated information
As simplified by official websites.
Q.97The EUCount() function should display the output as:?
Q.98 Write the outputs of the SQL queries (i) to (iii) based on the relations Teacher
and Posting given below:
Table : Teacher
T_ID Name Age Department Date_of_join Salary Gender
1 Jugal 34 Computer Sc 10/01/2017 12000 M
2 Sharmila 31 History 24/03/2008 20000 F
3 Sandeep 32 Mathematics 12/12/2016 30000 M
4 Sangeeta 35 History 01/07/2015 40000 F
5 Rakesh 42 Mathematics 05/09/2007 25000 M
6 Shyam 50 History 27/06/2008 30000 M
7 Shiv Om 44 Computer Sc 25/02/2017 21000 M
8 Shalakha 33 Mathematics 31/07/2018 20000 F
Table : Posting
P_ID Department Place
1 History Agra
2 Mathematics Raipur
3 Computer Science Delhi
i. SELECT Department, count(*) FROM Teacher
GROUP BY Department;
ii. SELECT Max(Date_of_Join),Min(Date_of_Join)
FROM Teacher;
iii. SELECT Teacher.name,Teacher.Department,
Posting.Place FROM Teachr, Posting WHERE
Teacher.Department = Posting.Department AND
Posting.Place=”Delhi”;
Q.99 Write a function in Python PUSH(Arr), where Arr is a list of numbers. From
this list push all numbers divisible by 5 into a stack implemented by using a
list. Display the stack if it has at least one element, otherwise display
appropriate error message.
OR
Write a function in Python POP(Arr), where Arr is a stack implemented by a
list of numbers. The function returns the value deleted from the stack.
Q.100 MyPace University is setting up its academic blocks at Naya Raipur
and is planning to set up a network. The University has 3 academic
blocks and one Human Resource Center as shown in the diagram
below:
Center to Center distances between various blocks/center is as follows:
Law Block to business Block 40m
Law block to Technology Block 80m
Law Block to HR center 105m
Business Block to technology
Block
30m
Business Block to HR Center 35m
Technology block to HR center 15m
Number of computers in each of the blocks/Center is as follows:
Law Block 15
Technology Block 40
HR center 115
Business Block 25
a) Suggest the most suitable place (i.e., Block/Center) to install
the server of this University with a suitable reason.
b) Suggest an ideal layout for connecting these blocks/centers for a
wired connectivity.
c) Which device will you suggest to be placed/installed in each
of these blocks/centers to efficiently connect all the
computers within these blocks/centers.
d) Suggest the placement of a Repeater in the network
with justification.
e) The university is planning to connect its admission office in
Delhi, which is more than 1250km from university. Which
type of network out of LAN, MAN, or WAN will be formed?
Justify youranswer.
Q101 Write SQL commands for the following queries (i) to (v) based on the
relations Teacher and Posting given below:
Table : Teacher
T_ID Name Age Department Date_of_join Salary Gender
1 Jugal 34
Computer
Sc
10/01/2017 12000 M
2 Sharmila 31 History 24/03/2008 20000 F
3 Sandeep 32 Mathematics 12/12/2016 30000 M
4 Sangeeta 35 History 01/07/2015 40000 F
5 Rakesh 42 Mathematics 05/09/2007 25000 M
6 Shyam 50 History 27/06/2008 30000 M
7 Shiv Om 44
Computer
Sc
25/02/2017 21000 M
8 Shalakha 33 Mathematics 31/07/2018 20000 F
Table : Posting
P_ID Department Place
1 History Agra
2 Mathematics Raipur
3 Computer Science Delhi
i. To show all information about the teacher of History
department.
ii. To list the names of female teachers who are in Mathematics
department.
iii. To list the names of all teachers with their date of joining in
ascending order.
iv. To display teacher’s name, salary, age for male teachers only.
v. To display name, bonus for each teacher where bonus is 10%
of salary.
Q.102 A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price].
i. Write a user defined function CreateFile() to input data for a
record and add to Book.dat .
ii. Write a function CountRec(Author) in Python which accepts the
Author name as parameter and count and return number of
books by the given Author are stored in the binary file
“Book.dat”
OR
A binary file “STUDENT.DAT” has structure (admission_number, Name,
Percentage). Write a function countrec() in Python that would read contents
of the file “STUDENT.DAT” and display the details of those students whose
Percentage is above 75. Also display number of students scoring above 75%
Q.103 state weather true or false:
Variable declaration is implicit in Python.
a. dict_exam.update(dict_result)
b. dict_exam + dict_result
c. dict_exam.add(dict_result)
d. dict_exam.merge(dict_result)
Which of the following will be the correct output if the given expression is evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
Q.107 Select the correct output of the code:
a = a.split(‘2’)
print (b)
(a) a+ (b) r+ (c) w+ (d) None of the above
………………….command is used to remove the primary key from the table in SQL.
Q.110 Which of the following commands will delete the table from MYSQL
database?
(a)DELETETABLE
(b)DROPTABLE
(c)REMOVETABLE
(a)Statement3
(b)Statement4
(c)Statement5
Q112. Fill in the blank:……………………is a non-key attribute, whose values are derived from the primary key of some other
table.
(a)PrimaryKey
(b)ForeignKey
(c)CandidateKey
(d) seek.file_object(offset)
The SELECT statement when combined with…………………. clause returns records without repetition.
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
……………………is a communication methodology designed to deliver both voice and multimedia communications over Internet
print(15.0 / 4 + (8 + 3.0))
117. Which function is used to display the total number of records from table in a database?
(a) sum(*)
(b) total(*)
(c) count(*)
(d) return(*)
118. To establish a connection between Python and SQL databases, connect() is used. Which of the following arguments may
(a) host
(b) database
(c) user
(d) password
Q119 and 120are 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
Q.121. Assertion (A):- If the arguments in the function call statement match the number and order of arguments as defined
argument(s).
Q122. Assertion (A): CSV (Comma Separated Values) is a file format for data storage that looks like a text file.
Reason (R): The information is organized with one record on each line and each field is separated by comma.
122. Rao has written a code to input a number and check whether it is prime or not. His code is having errors. Rewrite the
Q123. Write two points of difference between Circuit Switching and Packet Switching. OR
Q125. Explain the use of ‘Foreign Key’ in a Relational Database Management System. Give example to support your answer.
Q126 (a) Write the full forms of the following:
OR
OR
Categorize the following commands as DDL or DML: INSERT, UPDATE, ALTER, DROP 2
Table: Branch
ACode City
A01 Delhi
A02 Mumbai
A01 Nagpur
What will be the output of the following statement?
(b) Write the output of the queries (i) to (iv) based on the table, TECH_COURSE given below:
(ii) SELECT TID, COUNT(*), MIN(FEES) FROM TECH_COURSE GROUP BY TID HAVING COUNT(TID)>1;
(iv) SELECT AVG(FEES) FROM TECH_COURSE WHERE FEES BETWEEN 15000 AND 17000;
Q.130. Write a method COUNTLINES() in Python to read lines from text file
‘TESTFILE.TXT’ and display the lines which are not starting with any vowel. 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.
Write a function ETCount() in Python, which should read each character of a text file “TESTFILE.TXT” and then count and
display the count of occurrence of alphabets E and T individually (including small cases e and t too).
Example:
Q.131 (a) Write the outputs of the SQL queries (i) to (iv) based on the
Table : Teacher
Table : Placement
Q.134ii) SELECT Name, Salary, T.Department, Place FROM Teacher T, Placement P WHERE T.Department = P.Department
AND Salary>20000;
Q136. Write a function INDEX_LIST(L), where L is the list of elements passed as argument to the function. The function
returns another list named ‘index list’ that stores the indices of all Non-Zero Elements of L.
For example:
If L contains [12,4,0,11,0,56]
Q137. A list contains the following record of a customer: [Customer_name, Phone_number, City]
Write the following user-defined functions to perform given operations on the stack named ‘status’:
(ii) Pop_element() – To Pop the objects from the stack and display them. Also, display “Stack Empty” when there are no
For example:
[“Julee”, “8888888888”,”Mumbai”]
[“Gurdas”,”9999999999”]
[“Gurdas”,”9999999999”]
Stack Empty
OR
Q.138Write a function in Python, Push(SItem) where , SItem is a dictionary containing the details of stationary items–
{Sname:price}.
The function should push the names of those items in the stack who have price greater than 75. Also display the count of
For example:
Ditem={“Pen”:106,”Pencil”:59,”Notebook”:80,”Eraser”:25}
Pen
Q.139. 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 blocks/locations and other given parameters.
Q.140(i) Suggest the most appropriate block/location to house the SERVER in the Kashipur campus (out of the 3 blocks) to
Q141(ii) Suggest a device/software to be installed in the Kashipur Campus to take care of data security.
Q142(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to economically connect various blocks
within the
Kashipur Campus.
(iv) Suggest the placement of the following devices with appropriate reasons:
a. Switch / Hub
b. Repeater
(v) Suggest a protocol that shall be needed to provide Video Conferencing solution between Kashipur Campus and Mussoorie
Campus.
p=5
a=10
b=5 sum(a,b)
sum(r=5,q=1)
(b) The code given below inserts the following record in the table Student:
• Username is root
• Password is tiger
• The details (RollNo, Name, Clas and Marks) are to be accepted from the user.
Q.144Write the following missing statements to complete the code: Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Student.
con1=mysql.connect(host=”localhost”,user=”root”, 2+3
password=”tiger”, database=”school”)
mycursor= #Statement 1 rno=int(input(“Enter Roll Number :: “)) name=input(“Enter name :: “) clas=int(input(“Enter class ::
values({},'{}’,{},{})”.format(rno,name,clas,marks)
#Statement 2
# Statement 3
OR
s=”welcome2cs”
n = len(s) m=””
else:
m = m +’&’ print(m)
(b) The code given below reads the following record from the table named student and displays only those records who have
• Username is root
• Password is tiger
Statement 2 – to execute the query that extracts records of those students whose marks are greater than 75.
marks are greater than 75) into the object named data, from the table student in the database.
“)
#Statement 2
print(i) print()
Q145. What is the advantage of using a csv file for permanent storage?
Q146 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 ‘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
(i) add() – To accept and add data of an employee to a CSV file ‘furdata.csv’. Each record consists of a list with field elements
as fid, fname and fprice to store furniture id, furniture name and furniture price respectively.
(ii) search()- To display the records of the furniture whose price is more than 10000. 5
Class 12 Computer Science Sample Question Paper 2023: SECTION – E
Q147. Navdeep creates a table RESULT with a set of records to maintain the marks secured by students in Sem 1, Sem2,
Sem3 and their division. After creation of the table, he has entered data of 7 students in the table. 1+1+2
Q.148(i) Identify the most appropriate column, which can be considered as Primary key.
Q149(ii) If two columns are added and 2 rows are deleted from the table result, what will be the new degree and cardinality
Roll No- 108, Name- Aadit, Sem1- 470, Sem2-444, Sem3- 475, Div – I.
b. Increase the SEM2 marks of the students by 3% whose name begins with ‘N’.
Q151. Aman is a Python programmer. He has written a code and created a binary file record.dat with employeeid, ename
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.
As a Python expert, help him to complete the following code based on the requirement given above:
import #Statement 1
fin=open(“record.dat”,”rb”)
try:
found=True
:: “))
pickle. #Statement 4
else:
pickle.dump(rec,fout) except:
break
if found==True:
else:
fout.close()
Q.152(i) Which module should be imported in the program? (Statement 1)
Q153(ii) Write the correct statement required to open a temporary file named temp.dat. (Statement 2)
data from the binary file, record.dat and in Statement 4 to write the updated data in the file, temp.dat?