You are on page 1of 17

Class – XII –Pre-Board-Set-A

Maximum Marks: Time Allowed :1:30 hours

Question : Vivek is a software developer with a reputed firm. He has been given the task to
computerize the operations for which he is developing a firm which will accept customer data as
follows: The data to be entered is: Name, Age, Items Bought, Total Amount.
Q.1 Choose the most appropriate data type to store the above information inthe
given sequence.
A. string, tuple,float,integer B. string, integer, dictionary,integer
C.string, integer,tuple,float D. string, integer, list,dictionary

Q.2 Now the data of each customer needs to be organized in such that the items
bought followed by the itemprice.
A.List B.Dictionary C.NestedDictionary D.Tuple

Q.3 Now to calculate total bill amount of customers, Vivek can use which data
type to store thesum.
A.Integer B.Float C.List D.Tuple

Q.4 In order to calculate the total bill amount for 15 customers, Vivek
Statement 1. May use a variable of the type float to store the sum.
Statement 2. May use a loop to iterate over the values

a.Both statements are correct.


b.Statement 1 is correct, but statement 2 is not.
c.Both statements are incorrect.
d.Statement 1 is incorrect but statement 2 is correct.
Q.5 Vivek wants to update name of the customer in list. Which function from the
given option can be used.
L=[“Mayank”, 18]
A.L[0]=“Ajay” B.update(“Ajay”)
C.L[1]=“Ajay” D.L[0]=update(“Ajay”)

Question :
print("Enter Marks Obtained in 5 Subjects: ")
markOne =int(input())
markTwo = int(input())
markThree = int(input())
markFour = int(input())
markFive =int(input())
tot = markOne+markTwo+markThree+markFour+markFive
1
avg = tot/5

if avg>=91 and avg<=100:


print("Your Gradeis A1") #Statement 1
elif avg>=81 and avg<91:
print("Your Gradeis A2") #Statement 2
elif avg>=71 and avg<81:
print("Your Gradeis B1") #Statement 3
elif avg>=61 and avg<71:
print("Your Grade is B2")
elif avg>=51 and avg<61:
print("Your Grade is C1")
elif avg>=41 and avg<51:
print("Your Grade is C2")
elif avg>=33 and avg<41:
print("Your Grade is D")
elif avg>=21 and avg<33:
print("Your Grade is E1")
elif avg>=0 and avg<21:
print("Your Grade is E2")
else:
print("InvalidInput!") #Statement4
On the basis of the above code, choose the correct option which will be executed when different
inputs are given.
Q.6 If markOne,markTwo,markThree,markFour=100,97,82,85 and markFive=
“Nil” then total will be
A.364 B. value error C.Syntax Error D.TypeError
Q.7 If avg= “Nil” then which statement will execute.
A.Statement1 B.Statement 2 C.Statement 3 D. Statement 4
Q.8 If markOne,markTwo,markThree,markFour,markFive=100,95,90,80,85then
which statement willexecute.
A.Statement1 B.Statement 2 C.Statement 3 D. Statement 4
Q.9 If markOne,markTwo,markThree,markFour,markFive=100,83,92,80,100then
which statement willexecute.
A.Statement1 B.Statement 2 C.Statement 3 D. Statement 4

Q.10 If avg=81, then which statement willexecute.


A.Statement1 B.Statement 2 C.Statement 3 D. Statement 4

Question : Ravi is looking for his dream job but has some restrictions. He loves Delhi and
would take a job there if he is paid over Rs.40,000 a month. He hates Chennai and demands at
least Rs. 1,00,000 to work there. In any another location he is willing to work for Rs. 60,000 a
month. The following code shows his basic strategy for evaluating a job offer. Code:
pay=
location=

2
if location == "Mumbai":
print ("I’ll take it!") #Statement 1
elif location =="Chennai":
if pay < 100000:
print("Noway") #Statement2
else:
print("I am willing!") #Statement3
elif location == "Delhi" and pay > 40000:
print("I am happy to join") #Statement 4
elif pay >60000:
print("I accept the offer") #Statement5
else:
print("No thanks, I can find something better") #Statement6

On the basis of the above code, choose the right statement which will be executed when different
inputs for pay and location are given.

Q.11 Input: location = "Chennai”, pay =50000


A.Statement1 B.Statement 2 C.Statement 3 D. Statement 4

Q.12 Input: location = "Chennai", pay =150000


A.Statement1 B.Statement 2 C.Statement 3 D. Statement 6

Q.13 Input- location = "Any Other City", pay =1


A. Statement1 B.Statement 2 C.Statement 4 D. Statement 6

Q.14 Input location = "Delhi", pay =400000


A.Statement6 B.Statement 5 C.Statement 4 D. Statement 3

Q.15 Input- location = "Lucknow", pay =70000


A.Statement2 B.Statement3 C.Statement4 D. Statement 5

Question :Vimal prepare a code for different conditions and take different inputs in variable
str1. What will be the output for the different inputs given below:
str1=" "
str2=""
I=0
while I<len(str1):
if str1[I]>="A" and str1[I]<="M":
str2=str2+str1[I+1]
elif str1[I]>="0" and str1[I]<="9":
str2=str2+str1[I-1]
else:
str2=str2+"*"

3
I=I+1
print(str2)

Q.16 If input will be str1= “Exam2021” then output willbe


A.X***M202 B.X**M2021
C.x***m201 D.x***m202
Q.17. If input will be str1= “CBSE-Exam” then output will be
A.Bs*-*x*** B.BS*-*x***
C.BS*-*x** D.BS**-*x**
Q.18 If input will be str1= “PT1” then output willbe , If input will be str1= “ABCD” then
output willbe
A. **T, Error : String index out of range B .*T*, BCD C.T**, BCD* D.**t, ABCD
Q.19.If input will be str1= “xyzA” then output willbe
a. **A B.***A C.*xyz D. Error : String index out ofrange

Question : If a user change its passing parameter of function calling display( ). What will be the
output of the following code.

defdisplay(a):
a1=""
for i in range(0,len(a)):
if(a[i].isspace()):
a1=a1+"*"
elif(a[i].isdigit()):
a1=a1+"&"
elif(a[i].isalpha()):
a1=a1+a[i].upper()
print(a1)
display(" ")

Q.20. If passing parameter will be “Python”, then output willbe


b. PYTHON B.Python C.python D. None ofthese

Q.21 If passing parameter will be “Exam2021”, then output willbe


a. Exam&&&& B.EXAM**** C. EXAM&&&& D.Exam****

Q.22 If passing parameter will be “PT1”, then output willbe


a. pt& B.PT* C.Pt& D.PT&

Question : Assume, you are given two lists: a =[1,2,3,4,5] b =[6,7,8,9]


The task is to create a list which has all the elements of a and b in one dimension.
Q.23 If Output :a = [1,2,3,4,5,6,7,8,9] , Which of the following option would you choose?
a. A.append(b) B.A.extend(b) C. Any of the above D. None of these

4
Q.24 If Output : a = [1,2,3,4,5,[6,7,8,9]] , Which of the following option
would you choose?
a. a.append(b) B.a.extend(b) C. Any ofthe above D. None of these

Question: Suppose you are defining a tuple given below: tup = (1, 2, 3, 4, 5)

Q.25 You want to update the value of this tuple at 2nd index to 10. Which of the
following option will you choose?
a. tup(2)=10 B.tup[2]=10 C.tup{2}=10 D. None ofthese

Q.26 You want to check the index of value 5. Which of the following option will you
choose?
a. tup.index(5) B.tup=index(5) C.tup.index(4) D.tup=index(4)

Q.27 You want to check the minimum value of tup. Which of the following option will
you choose?
a. min=tup() B.tup=min(1) C.tup=min() D.min(tup)

Q.28 You want to check the length of tup. Which of the following option will you
choose?
a. len.tup B.len(tup) C.len=tup D. None ofthese

Q.29 You want to delete tup. Which of the following option will youchoose?
a. delete(tup) B.remove(tup) C.del tup D.tup.remove()

Q.30 Which of the following function headers is correct?


a. Def f(a=1,b): B.def f(a=1,b,c=2):
C.def f(a=1,b=1,c=2): D.def f(a=1,b=1,c=2,d):

Q.31 Which of the following function calls will cause Error while invoking/calling the
below function definition?
def test(a,b,c,d)
A.test(1,2,3,4) B.test(4,5,6,7)
C.test(a=1,b=2,c=3,d=4) D.test(a=1,2,3,4)

Q.32 Which of the following function calls can be used to invoke/calling the below
function definition?
def test(a,b,c,d)
A.test(1,2,3,4) B.test(a=1,2,3,4)
C.test(a=1,b=2,c=3,4) D.test(a=1,b=2,3,4)

5
Q.33 What is a variable defined outside all the function referred to as?
a. A static variable B. A global variable
C. A local variable D. An automatic variable

Q.34 What is a variable defined inside a function referred to as?


a. A static variable B. A global variable
C. A local variable D. An automatic variable

Q.35 What will be the output of the following python code:


a=10
def call():
global a
a=15
b=20
print(a)
call()

a. 10 15 B.15 C. 10 D. 15 20

Q.36 What is the output of the following code?


def func(a,b,c):
x=4
c+=x
c*=globals()['x']
b+=c
return a,b,c
y=1
x=2
z=5
x,y,z=func(y,x,z)
print(x,y,z)
a. 5 18 25 b. 1 20 18 c. 1 13 11 d. 1 9 7

Question : Consider the following python code:


def Add(x,y,z):
print(x+y+z)
Add(10,20,30) #Invoke1
Add(x=20, y=40,z=60) #Invoke2

Q.37 Which type of argument used in #Invoke1?


a. Positional Argument B. Default Argument
C. Keyword Argument D. Variable length Argument

6
Q.38 Which type of argument used in #Invoke2?
a. PositionalArgument B. DefaultArgument
C. KeywordArgument D. Variable lengthArgument
Q.39 What will be the output of following code:
def func(a=10,b=20):
return a+b
print(func(a=1))
print(func(b=1))

a. 21 11 B.11 21 C.30 2 D. None of these

Q.40 What will be the output of the following code:


def calc(x):
r=2*x**2
return r
print(calc(3))
a. 8 B.16 C. 20 D. 18

Q.41 What will be the output of the following expression:


>>> 5//20
A.5 B.20 C.4 D.0

Q.42 What will be the output of the following expression:


>>> 50//6
A.50 B.6 C. 0 D.8

Q.43 What will be the output of the following expression:


>>> 21%5
A.0 B.4 C.5 D.1

Q.44 What will be the output of the following expression:


>>> 6%30
A.0 B.6 C. 30 D.5

Q.45 What will be the output of the following expression:


>>> (50/5**2)
A.2.0 B.2 C.100.0 D.100
Q.46 Which of the following is an invalid variable?
a. hello_1 B.hello21 C.Hello_234 D.3Hello

Q.47 Which of the following is not a keyword?


a. if B. nonlocal C.global D.local

Q.48 Which value type does input() return?


7
a. Boolean B.String C.Int D.Float
Q.49 What will be the status of the following list after third iteration of bubble sort arranging it
in descending order? 95,-1,38,2,100,65,78.
a. [95,100,65,78,38,2,-1] b. [95,100,65, 2,-1, 78,38]
c. [95,38,2,-1, 100,65,78] d. None
Q.50 What will be the status of the following list after third iteration of insertion sort for
arranging it in descending order? 22,54,12,90,55,78
a. [90, 12,55,54,22 ,78] b. [90,54,22,12,55,78]
c. [90,54, 55,78,22,12] d. None

Q.51 Priya is creating an inventory management project for her father. She has to maintain a
price list and create a module for stock management. She is confused in choosing the
data type she has to work with. Which data type will you suggest her?
A. List B. Tuple C. Dictionary D. Files

Q.52. On working with list data type, Meena is facing a problem. On certain condition she is
creating a duplicate copy of list for backup purpose using the code list2=list1. But she
couldn’t effectively maintain the list as whatever changes made in the new list is
affecting the old list. What is the problem with her code?
a. She created a shallow copy. b.She created a deep copy.
c. She violated the mutability concept. d. Both lists took different memory location.

Q.53. Based on the situation given in question no.52, what modification can be done on the
code to meet the requirement.
A. list2=list(list1)
B. list1= list(list2)
C. list1=copy(list2)
D. list2=list.copy(list1)

Q.54 Ranjit created a sequence of data in form of tuple. Now he wants to add few more
elements to the same tuple. What will happen when he does so?
a. The operation is carried successfully.
b. The operation is aborted due to error
c. The operation leads to an exception
d. A tuple is created with additional elements in a new memory space.

Q.55 What is returned while using sort () method in list operations?


A. The list elements are sorted in ascending order and the result is returned.
B. The list elements are sorted in ascending order and return nothing.
C. The list elements are sorted in descending order and the result is returned.
D. The list elements are sorted in descending order and return nothing.

8
Q.56 Which of the following is not a valid string operation in Python?
a. ‘abc’+’abc’
b. ’abc’*3
c. ‘abc’+3
d. ‘abc’.upper()

Q.57 Which of the following creates a tuple?


a. tuple1=(“a”,”b”)
B. tuple*1+=(“a”,”b”)
C. tuple1=(5)*2
D. None of the above

Q.58 Which of the following statement is not correct regarding the file access modes?
a. ‘r+’ opens a file for both reading and writing. Fileobject points to its beginning.
b. ‘w+’opens a file for both writing and reading. Adds at the end of the existing file
if it exists and creates a new one if it does not exist.
c. ‘wb’opens a file for reading and writing in binary format. Overwrites the file if it
exists and creates a new one if it does not exist.
d. ‘a’opens a file for appending.

Q.59 The file pointer is at the start of the file if the file exists. Which of the following
statements correctly explain the function of seek () method?
A. tells the current position within the file.
B. determines if you can move the file position or not.
C. indicates that the next read or write occurs from that position in a file.
D. moves the current file position to a given specified position.

Q.60 What is the output of the following statement?


def sum(*a):
s=0
for i in a:
s=s+i
return(s)
print(sum(1,3,5), end=' ')
print(sum(sum(1,2,3,4,5),6,8))
a. 9 9 b. 9 15 c. 9 29 d. 15 14

CASE BASED QUESTIONS:


Manoj wants to maintain the history of phone calls that he makes every day.
Mobile_number and customer_name are the attributes. Initially he has to create an empty
dictionary and then he has to update the dictionary as and when the call is made. At the end
of the day he has to transfer the dictionary contents to a new dictionary that should be named
as per the date the calls are made and he should empty the working dictionary for the next
9
day’s work. Whenever his manager comes he has to generate report based on the manager’s
query. Help him by answering all his queries.

Q 61.Which attribute has to be fixed as key and value?


A. Mobile-number as key and customer_name asvalue.
B. Mobile_number as value and customer_name as key.
C. Mobile_number as key and customer_name asvalue.
D. Mobile_number as key and customer-name asvalue
Q 62.How can he create an empty dictionary?
A. Call_register={}
B. Call_register=dict()
C. Both A &B
D. None of the above

Q.63.After making a first call to Rohan whose number is 8124596780 how will he add it to the
dictionary?
a. Call_register*‘Rohan’+=8124596780
b. Call_register.push*‘Rohan’+=8124596780
c. Call_register[8124596780]+=‘Rohan’
d. Call_register['Rohan']=8124596780
Q.64. How can he show the entire call history to his manager at end of the day?
A. Call_register.get()
B. Call_register.items()
C. Call_register.keys()
D. Call_register(keys)

Q.65 When the manager wants to check only the names of the customer he called, then how can
he generate it.
A. Call_register.get()
B. Call_register.items()
C. Call_register.keys()
D. Call_register.values()

ASSERTION & REASONING BASED QUESTIONS

Q. 66 Assertion - close () method closes the file and frees the memory space acquired by that
file.
Reason - one should always close their files, in some cases, due to buffering, changes made to a
file may not show until the file is closed.
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 isfalse.
10
D - A is false but R istrue.
Q.67 Assertion - The with statement simplifies the working with files but does not support
exception handling.
Reason – The with statement will automatically close the file after the nested block of
code.
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.
Q-68 Assertion- To open a file one should use the open() function, open() is a built in
function
Reason – The open () functions returns a file object, it is used to read or modify the
file accordingly.

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.
Q-69 Assertion: The mode a+ allows one to open a binary file in append mode.
Reason: Append mode allows to add contents to existing 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.


Q-70 Assertion : Pickle module is to be imported to work with a binary file.
Reason : It retains the structure of the mutable data types and allows effective
manipulations over the data.
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.

Q-71 Assertion - A CSV file is a type of plain text file that uses specific structuring to
arrange tabular data.
Reason - A CSV file is a simple text file where each line contains a list of values
11
delimited by commas.

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 isfalse.
D - A is false but R istrue.

Q-72 Assertion - In a function header, any parameter cannot have a default value unless all
parameters appearing on its right have their default values.
Reason - Non- default arguments cannot follow default arguments.

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.

Q-73 Assertion- Having keyword arguments after positional arguments will result into
error. Reason – an argument list must contain positional arguments followed by any
keyword arguments.

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 isfalse.
D - A is false but R istrue.
Q-74 Assertion - A function ends the moment it reaches a return statement or all the
statements in function body have been executed.
Reason – Return statement ends a function execution even if it is in the middle of the
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 isfalse.
D - A is false but R istrue.

Q-75 Assertion- One should avoid using global statements in python program
Reason – Global statements cannot be reverted in a program

12
run. 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.

COMPLETE THE CODE WITHAPPROPRIATEANSWER:

Preethi wants to read the contents of a file “test.csv” which is stored in ‘d:’ drive. She has
written the code partially. Help her to complete
import ________ # line1
f=open(______________) # line2
data=__________(f) # line3
for row in _____ : # line4
print(row) # line5
______ #line6

Q.76. What module should be imported by Keerthi inline1?


A. pickle
B. csv
C. Csv
D. Pickle

Q.77.What argument she should pass inside the open () function inline2?
A. “test.csv”,”r”
B. “test.csv”,”rb”
C. “d:/test.csv”,”r”
D. “d:/Test.csv”,”r”
Q.78. Help her to create a csv object in line3 by choosing the correct option.
A. csv.reader
B. csv.writer
C. csv.readrows
D. csv.Writerows
Q.79. Complete the header part of the for loop with the appropriate option.
A. test
B. f
C. data
D. csv
Q.80. Fill line6 with the correctoption.
A. csv.close()

13
B. close()
C. f.close()
d. close(f)

Vinay is writing a program to search for the details a particular student. He has got difficulties in
completing the code. Help him to complete it.
import __________ as P # line 1
L=[ ]
rno=int(input(“Enter the rno to search:”))
______ open(‘student’,rb) as ______: # line 4
L=___________(f) # line 5
for x in ______: # line 6
if x[0]==roll:
print(“name=”,x[1])
print(“total=”,x[5])
_______ # line 10
else :
print(“not found”)
Q.81. What module should be imported by Keerthi inline1?
A. pickle
B. csv
C. binary
D. Pickle
Q.82. Complete the open()statement
A. filehandle,filename
B. filename,filehandle
C. with,filehandle
D. with,f
Q.83. Help sunil to complete line5.
A. P.load()
B. pickle.load()
C. f.dump()
D. pickle.dump()
Q.84. The iterating variable x has to be iterated over,
A. P
B. L
C. f
D. rb
Q.85. Complete line 10 with a relevant jump statement.
A. continue
B. goto
C. break

14
D. exit

Q.86. Which of the following is the use of function in python?


a) Functions are reusable pieces of program
b) Functions don’t provide better modularity for your application
c) you can’t also create your own functions
d) All of the mentioned

Q.87. What is the output of the below program?


x = 15
def func(x):
print('x is',x)
x =2
print('Changed local x to',x)
func(x)
print('x is now', x)

a) x is now 15
b) x is now 2
c) x is now 100
d) None of the mentioned

Q.88. What is the output of below expression?


(2+3)*5//4+(4+6)/2

a. 11 b. 11.0 c. 9.0 d. 9

Q.89. What is the output of the below expression?

(2+3)**3-6/2
a. 121 b.121.0 c. 122.0 d. none

Q.90 What is the order of precedence of the arithmetic operations given below in python?

1. () 2.** 3. * 4. / 5. + 6. –

a. 1,2,3,4,5,6 b. 2,3,4,5,6,1 c. 1,3,2,6,4,5 d. 4,6,5,2,3,1

Q.91. Which of the following is a features of Doc String?

a) Provide a convenient way of associating documentation with Python modules,


functions, classes, and methods
b) All functions can contain a doc string
c) Doc strings can be accessed by the __doc__ attribute on objects
15
d) All of the mentioned

Q.92 Which are the advantages of functions in python?


a)Reducing duplication of code
b)Decomposing complex problems into simpler pieces
c)Improving clarity of the code
d) All of the mentioned

Q.93 What is the output of below program?

>>>int('101',2)
>>>int('A',16)

a. 10 5 b. 5 10 c. 1.01 A d . NONE

Q.94. What are the two main types of functions?


a) Customf unction
b) Built-in function & User defined function
c)User function
d) System function
Q.95. What is called when a function is defined inside a class?
a)Module
b) Class
c) Another function
d) Method.
Q.96 Which of the following is a practical application of random module in python?
a. shuffling deck of playing cards
b. pseudo random numbers on lottery scratch cards
c. Recaptcha in login forms
d. all the above

Q.97. Which of the following is not a mathematical function?

a. floor() b. pow() c. len() d. fabs()

Q.98. What is the output of below program?


import sys
sys.stdout.write('Happy \t')
sys.stdout.write('Childrens Day')

a. Happy Childrens Day


b. Happy Childrens Day
c. HappyChildrens Day

16
d.none

Q. 99. What is the output of the below program?


math.ceil(3.4)
math.floor(-45.1)

a. -46 4 b. 3 45 c. 4 -46 d. 3 46

Q.100. What is the output of the below program?

India="Ek Bharat Shreshtha Bharat"


with open("Myfile.txt",'w') as myfile:
myfile.write(India)
myfile = open("Myfile.txt")
vlist = list("aeiouAEIOU")
vc=cw=0
x = myfile.read()
for y in x:
if(y not in vlist):
vc+=1
else:
cw+=1

print(vc,cw)
myfile.close()

a. 7 19 b. 19 7 c. 4 5 d. none

17

You might also like