Class 12 Term - 01 Key
Class 12 Term - 01 Key
Q.No. Answer the following Questions: (All Questions are Compulsory) Marks
1. which of the following statement is not true for parameter passing to function? (1)
(a) you can pass positional arguments in any order.
(b) you can pass keyword argument in any order.
(c) you can call a function with positional any keyword arguments.
(d) positional arguments must be before keyword arguments in a function.
Ans: (a) you can pass positional arguments in any order.
2. A ______________ argument can be skipped in the function call statement. (1)
Ans: Default arguments.
3. Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90). (1)
What will be the output of print (tup1 [3:7:2])?
(a) (40,50,60,70,80) (b) (40,50,60,70) (c) [40,60] (d) (40,60)
Ans: (d) (40,60)
4. Which of the following is/are character set? (1)
(a) Alphabets (b) Digits (c) White space (d) all of these
Ans: (d) all of these
5. def Interest(p,c,t=2,r=0.09): (1)
return p*t*r
Considering the above defined function which of following function call are legal.
1. Interest(p=1000,c=5)
2. Interest(r=0.05,5000,3)
3. Interest(500,t=2,r=0.05)
4. Interest(c=4,r=0.12,p=5000)
(a) 1 , 2 and 4 (b) 2 & 3 (c) 1 &4 (d) 3 & 4
Answer: (c) 1 &4
6. Find the valid identifier from the following and state the reason. (1)
none, address, Name, pass.
Ans: none, address, Name are valid identifiers because pass is a keyword.
7. Assertion: pickling is the process whereby a python object hierarchy is converted (1)
into a byte-stream.
Reason: pickling process is used to work with binary files as a binary file works with
byte-stream.
(a) both A and R are true but R is not the correct explanation of A.
(b) both A and R are true and R is the correct explanation of A.
(c) A is true but R is false.
(d) R is true but A is false.
Ans: (a) both A and R are true but R is not the correct explanation of A.
8. The relative paths are relative to the current working dictionary? (True/false) (1)
Ans: True
9. In a stack, which item is accessed first. (1)
(a) The item above the first item.
(b) The item added least recently.
(c) The item added most recently.
(d) The item below the last item.
Ans: (c) The item added most recently.
10. Write Python code to open a file named "example.txt" in write mode and write the (1)
string "Hello, World!" to it with a file object called file.
Ans: With open ("example.txt", "w") as file:
file.write ("Hello, World!")
11. The peek operation refers to accessing/inspecting the top element in the stack. (1)
(True / False)
Ans: True.
12. Stack overflow condition is raised in ____________ operation whereas Stack (1)
underflow condition is raised in _____________ operations.
Ans: Push, Pop
13. To create a connection between MYSQL database and Python application connect() (1)
function is used. Which of the following are mandatory arguments required to
connect any database from Python.
(a) Username, Password, Hostname, Database Name, Port
(b) Username, Password, Hostname
(c) Username, Password, Hostname, Database Name
(d) Username, Password, Hostname, Port
Ans: (c)
14. Assertion (A): CSV file is a human readable text file where each line has a number (1)
of fields, separated by commas or some other delimiter. Reason
Reason (R): writerow() function can be used for writing into writer object.
(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
Ans: (b)
15. What is the output of following code: (1)
T=(100)
print(T*2)
(a) Syntax error (b) (200,) (c) 200 (d) (100,100)
Ans: (c) 200
16. Identify the output of the following Python statements. (1)
x = [[10.0, 11.0, 12.0],[13.0, 14.0, 15.0]]
y = x[1][2]
print(y)
(a) 12.0 (b) 13.0 (c) 14.0 (d) 15.0
Ans: (d) 15.0
17. Syntax of seek function in Python is myfile.seek(offset, reference_point) where (1)
myfile is the file object. What is the default value of reference_point?
(a) 0 (b)1 (c) 2 (d) 3
Ans: (a) 0
18. What will be the output of the following code? (1)
x=3
def myfunc():
global x
x+=2
print(x, end=' ')
print(x, end=' ')
myfunc()
print(x, end=' ')
(a) 3 3 3 (b) 3 4 5 (c) 3 3 5 (d) 3 5 5
Ans: (d) 3 5 5
19. What is the output of the following code snippet? (1)
def ChangeVal(M,N):
for i in range(N):
if M[i]%5 == 0:
M[i]//=5
if M[i]%3 == 0:
M[i]//=3
L = [58,77,75,19]
ChangeVal(L,4)
for i in L:
print(i,end="#")
(a) 58#77#15#19# (b) 58#70#15#19#
(c) 58#77#5#19# (d) 58#77#5#18#
Ans: (c) 58#77#5#19#
20. In ________ files each line terminates with EOL or ‘\n’ or carriage return, or ‘\r\n’. (1)
(a) Binary file (b) CSV file (c) Text file (d) Both (a) and (d)
Ans: (c) Text file
21. Expand: LIFO & FIFO (1)
Ans: Last In First Out & First In First Out
22. The writer() has how many mandatory parameters? (1)
Ans: 1
23. Nabithra is trying to read a list l1 from a binary file ‘num’. Consider the following (1)
code written by her.
import pickle
f1 = open("num",'rb')
l1=__________________#Statement 1
print(l1)
f1.close()
Identify the missing code in Statement 1.
(a) pickle.load(f1) (b) pickle.load(l1,f1)
(c) pickle.read(f1) (d) pickle.dump(l1,f1)
1 Aditya 2021
2 Arjun 2018
3 Aryan 2016
4 Sagar 2022
Read the questions given below and fill in the gaps accordingly: (1 + 1 + 2)
1.State the module name required to be written in Line-1.
2.Mention the name of the mode in which she should open a file.
3.Fill in the gaps for given statements – Line-2 and Line-3.
Ans:
1. csv
2. r mode
3. Line 2 – “client.csv”,”r” and Line 3 – reader
(b) The explicit conversion of an operand to a specific type is called ______.
Ans: Type casting.
40. (a) Write a function PUSH(L) and POP(Stk), where L is List of integers and Stk is a (3+1)
stack. In PUSH function create two stack StkO and StkE, then read the list L and
push all the even element in StkE and push all the odd element in StkO. At last
return both the stacks. In POP function pop the number from the stack and
display.
Ans:
def PUSH(L):
StkO = []
StkE = []
for i in L:
if i%2 == 0:
StkE.append(i)
else:
StkO.append(i)
return StkO, StkE
def POP(Stk):
if len(Stk) == 0
print(“Stack is Empty”)
else:
while len(Stk) != 0:
print(Stk.pop())
(2) The command to merge the dictionary Book with Library the command would
be:
a. d=Book+Library
b. print(Book+Library)
c. Book.update(Library)
d. Library.update(Book)
Answer: d. Library.update(Book)
(4) In order to check whether the key 2 is present in the dictionary Book, Ramesh
uses the following command:
>>> 2 in Book
He gets the answer ‘True’. Now to check whether the name ‘Madras Diaries’ exists
in the dictionary Library, he uses the following command:
>>> ‘Madras Diaries’ in Library
But he gets the answer as ‘False’. Select the correct reason for this:
a. We cannot use the in function with values. It can be used with keys only.
b. We must use the function Library.values() along with the in operator
c. We can use the Library.items() function instead of the in operator
d. Both b and c above are correct.
Answer: b. We must use the function Library.values() along with the in operator
(5) What are in and not in membership operators in dictionary? Write its syntax.
*****************