Amity International School, Sector - 1, Vasundhara SESSION 2021 - 22 Class Xii - Computer Science Python Revsion Tour - Revision Worksheet MCQ

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

AMITY INTERNATIONAL SCHOOL, SECTOR – 1, VASUNDHARA

SESSION 2021 -22


CLASS XII – COMPUTER SCIENCE
PYTHON REVSION TOUR – REVISION WORKSHEET
MCQ

1.The keys of a dictionary must be of _________ data


type.
a.integer b. mutable c. immutable
d. None of these

2.Consider the code given below, identify the line of


code that will cause an error?
num=[5,4,3,[2],1]
i.print(num[0])
ii. print(num[3][0])
iii. print(num[5])
iv. print(num[3][1])

a.Line iii b. Line ii c. Line iv


d.Line iv and iii

3.Which of the following functions return the last


three characters of a string s=”last” ?
a.s[1: ] b. s[ 3: ]
c. s[-3:] d. s[:-3]

4.What is the output of the following code?


str1=”Mission999”
str2=”999”
print(str1.isdigit( ), str1.isdigit( ))

a. False True b. False False c. True


False d. True True
5.Which of the following options will not result in
an error in Python, where tp=(5,2,7,0,3)?
a. tp[1]=2 b. tp.append(2) c.
tp1=tp+tp d. tp.sum( )

6.uniform() function belongs to _________ module.


a. pickle b. math
c. random d. statistics

7. What will be the output after the following


statements?
a = 27 / 3 % 2 * 4**2
print(a)
a. 0 b. 16.0 c. 32 d.
4.0

8.Write output of the following expression: 3+3*2 >


2+3-4 and 5%2**5.
a. 5 b. 6 c. True
d. False

9.What will be possible cause of error that will


occur when you execute the following code?
abc=xyz
a. TypeError b. ValueError
c. NameError d. KeyError

10. What will be the output of the following


statement?
print(int(6 == 6.0) * 3 + 4 % 5)
a.22 b. 15 c. 18
d. 7

11. Find the invalid identifier from the following


a) MyName b) true
c) 2ndName d) My_Name

12. Identify the valid arithmetic operator in


Python from the following.
a) ? b) < c) **
d) and

13. User input is read as while using input()


function.
a. Floating Decimal b. Text String c.
Boolean Value d. Integer

14. Which of the following is an invalid statement?


a) abc=1,000,000
b) a b c = 1000 2000 3000
c) a,b,c=1000,2000,3000
d) a=b=c=1,000,000

15. What is the maximum possible length of an


identifier?
a) 31 characters b) 63 characters
c) 79 characters d) none of the
mentioned
16. Select statements from the following that
removes the middle element 3 from it so that the
list AL= [1, 2,3, 4, 5] equal [1, 2, 4, 5]?

(a) del a[2] (b) a[2] =


[]
(c) Both a and b (d) none of these

17. Which of the following type conversions will


result in an error?
a) int (7.0+0.1) b) str (1.2 *
3.4)
c) float ("77" + ".0") d) str (9 /
0)

18. Which statement will give error when L = [1,


23, 'i', 6]
a) print(L= L+ L[0]) b) L=L*3
c) L[1:2]="New" d)print(L[::])

19. What will be printed when following code is


executed?

import random
Max=3
Div=1+random.randrange(0,Max)
for N in range(1,5):
print(100%Div, end="#")
print()
a. 0#0#0#0# b. 1#1#1#1 c. 2#2#2#2#
d. 3#3#3#
20. What is output of following code −
s = ''mnopqr ''
i = ''m ''
while i in s:
print('i', end= '' '')
(a) i i i i i i i i…….. (b) m m m m m ….. (c) m n
o p q r (d) no output

CASE STUDY BASED QUESTIONS


Q1. Krrishnav 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= _________
if location == "Mumbai":
print ("I’ll take it!")
#Statement 1
elif location == "Chennai":
if pay < 100000:
print ("No way")
#Statement 2
else:
print("I am willing!")
#Statement 3
elif location == "Delhi" and pay > 40000:
print("I am happy to join")
#Statement 4
elif pay > 60000:
print("I accept the offer")
#Statement 5
else:
print("No thanks, I can find something better")
#Statement 6

On the basis of the above code, choose the right


statement which will be executed when different inputs
for pay and location are given.

i. Input: location = "Chennai”, pay = 50000


a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4

ii. Input: location = "Surat" ,pay = 50000


a. Statement 2
b. Statement 4
c. Statement 5
d. Statement 6

iii. Input: location = "Surat" ,pay = 50000


a. Statement 2
b. Statement 4
c. Statement 5
d. Statement 6

iv. Input location = "Delhi", pay = 500000


a. Statement 6
b. Statement 5
c. Statement 4
d. Statement 3

v. Input- location = "Lucknow", pay = 65000


i. Statement 2
ii. Statement 3
iii. Statement 4
iv. Statement 5

Q2. Consider the following code and answer the questions


that follow:
Book={1:'Thriller', 2:'Mystery', 3:'Crime', 4:'Children
Stories'}
Library ={'5':'Madras Diaries','6': 'Malgudi Days'}

i. Ramesh needs to change the title in the dictionary


book from ‘Crime’ to ‘Crime Thriller’. He has written
the following command:
Book[‘Crime’]=’Crime Thriller’
But he is not getting the answer. Help him choose the
correct command:
a. Book[2]=’Crime Thriller’
b. Book[3]=’Crime Thriller’
c. Book[2]=(’Crime Thriller’)
d. Book[3] =(‘Crime Thriller’)

ii. 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)

iii. What will be the output of the following line of


code:
print(list(Library))

a. [‘5’,’Madras Diaries’,’6’,’Malgudi Days’]


b. (‘5’,’Madras Diaries’,’6’,’Malgudi Days’)
c. [’Madras Diaries’,’Malgudi Days’]
d. [‘5’,’6’]

iv. 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.

v. With reference to the above declared dictionaries,


predict the output of the following code fragments
Q3. Priyank is a software developer with a reputed firm.
He has been given the task to computerise the operations
for which he is developing a form which will accept
customer data as follows:
The DATA TO BE ENTERED IS :
a. Name
b. Age
c. Items bought( all the items that the customer
bought)
d. Bill amount

i. Choose the most appropriate data type to store the


above information in the given sequence.
a. string, tuple, float, integer
b. string, integer, dictionary, float
c. string, integer, integer, float
d. string, integer, list, float

ii. Now the data of each customer needs to be organised


such that the customer can be identified by name followed
by the age, item list and bill amount. Choose the
appropriate data type that will help Priyank accomplish
this task.
a. List
b. Dictionary
c. Nested Dictionary
d. Tuple

iii. Which of the following is the correct way of storing


information of customers named ‘Paritosh’ and ‘Bhavesh’
with respect to the option chosen above?
a. a.customers= {‘Paritosh’:24,[‘Printed Paper’, ‘
Penstand’], 3409, ‘Bhavesh’: 45,[‘A4 Rim’,’Printer
Cartridge’, ‘Pen Carton’, ‘Gift Wrap’], 8099.99 }
b. customers={‘Paritosh’:[24,[‘Printed Paper’, ‘
Penstand’], 3409], ‘Bhavesh’: [45,[‘A4 Rim’,’Printer
Cartridge’, ‘Pen Carton’, ‘Gift Wrap’], 8099.99] }
c. c.customers= [‘Paritosh’:24,‘Printed Paper’, ‘
Penstand’, 3409, ‘Bhavesh’: 45,‘A4 Rim’,’Printer
Cartridge’, ‘Pen Carton’, ‘Gift Wrap’, 8099.99 ]
d. customers=(‘Paritosh’:24,[‘Printed Paper’, ‘
Penstand’], 3409, ‘Bhavesh’: 45,[‘A4 Rim’,’Printer
Cartridge’, ‘Pen Carton’, ‘Gift Wrap’], 8099.99 )

iv. In order to calculate the total bill amount for 15


customers, Priyank
Statement 1. must 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 statemnt 2 is not.
c. Both statements ar incorrect.
d. Statement 1 is incorrect but statement 2 is correct.

You might also like