# 150+ MCQ Revision Tour of python class 12

Nov 29, 2021

## 150+ MCQ Revision Tour of python class 12

### Topic: Revision of python topics covered in class XI

1. Which of the following is a valid identifier:

a) 9type

b) _type

c) Same-type

d) True

b) _type

2. Which of the following is a relational operator:

a) >

b) //

c) or

d) **

a) >

3. Which of the following is a logical operator:

a) +

b) /=

c) and

d) in

c) and

4. Identify the membership operator from the following:

a) in

b) not in

c) both i & ii

d) Only i

c) both i & ii

5. Which one is a arithmetic operator:

a) not

b) **

c) both i & ii

d) Only ii

d) Only ii

6. What will be the correct output of the statement : >>>4//3.0

a) 1

b) 1.0

c) 1.3333

d) None of the above

b) 1.0

7. What will be the correct output of the statement : >>> 4+2**2*10

a) 18

b) 80

c) 44

d) None of the above

c) 44

8. Give the output of the following code:

>>> a,b=4,2

>>> a+b**2*10

a) 44

b) 48

c) 40

d) 88

a) 44

9. Give the output of the following code:

>>> a,b = 4,2.5

>>> a-b//2**2

a) 4.0

b) 4

c) 0

d) None of the above

a) 4.0

10. Give the output of the following code:

>>>a,b,c=1,2,3

>>> a//b**c+a-c*a

a) -2

b) -2.0

c) 2.0

d) None of the above

a) -2

11. If a=1,b=2 and c= 3 then which statement will give the output as : 2.0 from the following:

a) >>>a%b%c+1

b) >>>a%b%c+1.0

c) >>>a%b%c

d) a%b%c-1

b) >>>a%b%c+1.0

12. Which statement will give the output as : True from the following :

a) >>>not -5

b) >>>not 5

c) >>>not 0

d) >>>not(5-1)

c) >>>not 0

13. Give the output of the following code:

>>>7*(8/(5//2))

a) 28

b) 28.0

c) 20

d) 60

b) 28.0

14. Give the output of the following code:

>>>import math

>>> math.ceil(1.03)+math.floor(1.03)

a) 3

b) -3.0

c) 3.0

d) None of the above

a) 3

15.What will be the output of the following code:

>>>import math

>>>math.fabs(-5.03)

a) 5.0

b) 5.03

c) -5.03

d) None of the above

c) -5.03

16.Single line comments in python begin with……………….. symbol.

a) #

b) “

c) %

d) _

a) #

17.Which of the following are the fundamental building block of a python program.

a) Identifier

b) Constant

c) Punctuators

d) Tokens

a) Identifier

18.The input() function always returns a value of ……………..type.

a) Integer

b) float

c) string

d) Complex

c) string

19.……….. function is used to determine the data type of a variable.

a) type( )

b) id( )

c) print( )

d) str( )

a) type( )

20.The smallest individual unit in a program is known as a……………

a) Token

b) keyword

c) punctuator

d) identifier

a) Token

FLOW OF EXECUTION

#Decision making statements in python Statement

21. Which of the following is not a decision making statement

a) if..else statement

b) for statement

c) if-elif statement

d) if statement

b) for statement

22. …………loop is the best choice when the number of iterations are known.

a) while

b) do-while

c) for

d) None of these

b) for

23. How many times will the following code be executed.

a=5

while a>0:

print(a)

print(“Bye”)

a) 5 times

b) Once

c) Infinite

d) None of these

c) Infinite

24. What abandons the current iteration of the loop

a) continue

b) stop

c) infinite

d) Break

d) Break

25. Find the output of the following python program

for i in range(1,15,4):

print(i, end=’,’)

a) 1,20,3

b) 2,3,4

c) 1,5,10,14

d) 1,5,9,13

d) 1,5,9,13

26. …………loop is the best when the number of iterations are not known.

a) while

b) do-while

c) for

d) None of these

a) while

27.In the nested loop ……………..loop must be terminated before the outer loop.

a) Outer

b) enclosing

c) inner

d) None of these

c) inner

28. …………..statement is an empty statement in python.

a) pass

b) break

c) continue

d) if

a) pass

29. How many times will the following code be executed

for i in range(1,15,5):

print(i,end=’,’)

a) 3

b) 4

c) 1

d) infinite

a) 3

30. Symbol used to end the if statement:

a) Semicolon(;)

b) Hyphen(-)

c) Underscore( _ )

d) colon(:)

d) colon(:)

### String Methods and Built-in functions:

31. Which of the following is not a python legal string operation.

a) ‘abc’+’aba’

b) ‘abc’*3

c) ‘abc’+3

d) ‘abc’.lower()

c) ‘abc’+3

32. Which of the following is not a valid string operation.

a) Slicing

b) concatenation

c) Repetition

d) floor

d) floor

33. Which of the following is a mutable type.

a) string

b) tuple

c) int

d) list

d) list

34. What will be the output of the following code

str1=”I love Python”

strlen=len(str1)+5

print(strlen)

a) 18

b) 19

c) 13

d) 15

a) 18

35. Which method removes all the leading whitespaces from the left of the string.

a) split()

b) remove()

c) lstrip()

d) rstrip()

c) lstrip()

36. It returns True if the string contains only whitespace characters, otherwise returns False.

a) isspace()

b) strip()

c) islower()

d) isupper()

a) isspace()

37. It converts uppercase letter to lowercase and vice versa of the given string.

a) lstrip()

b) swapcase()

c) istitle()

d) count()

b) swapcase()

38.What will be the output of the following code.

Str=’Hello World! Hello Hello’

Str.count(‘Hello’,12,25)

a) 2

b) 3

c) 4

d) 5

a) 2

39.What will be the output of the following code.

Str=”123456”

print(Str.isdigit())

a) True

b) False

c) None

d) Error

a) True

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

Str=”python 38”

print(Str.isalnum())

a) True

b) False

c) None

d) Error

b) False

41.What will be the output of the following code.

Str=”pyThOn”

print(Str.swapcase())

a) PYtHoN

b) pyThon

c) python

d) PYTHON

a) PYtHoN

42.What will be the output of the following code.

Str=”Computers”

print(Str.rstrip(“rs”))

a) Computer

b) Computers

c) Compute

d) compute

c) Compute

43.What will be the output of the following code.

Str=”This is Meera\’ pen”

print(Str.isdigit())

a) 21

b) 20

c) 18

d) 19

d) 19

44.How many times is the word ‘Python’ printed in the following statement.

s = ”I love Python”

for ch in s[3:8]:

print(‘Python’)

a) 11 times

b) 8 times

c) 3 times

d) 5 times

d) 5 times

45.Which of the following is the correct syntax of string slicing:

a) str_name[start:end]

b) str_name[start:step]

c) str_name[step:end]

d) str_name[step:start]

a) str_name[start:end]

46.What will be the output of the following code?

A=”Virtual Reality”

print(A.replace(‘Virtual’,’Augmented’))

a) Virtual Augmented

b) Reality Augmented

c) Augmented Virtual

d) Augmented Reality

d) Augmented Reality

47.What will be the output of the following code?

print(“ComputerScience”.split(“er”,2))

a) [“Computer”,”Science”]

b) [“Comput”,”Science”]

c) [“Comput”,”erScience”]

d) [“Comput”,”er”,”Science”]

b) [“Comput”,”Science”]

48.Following set of commands are executed in shell, what will be the output?

>>>str=”hello”

>>>str[:2]

a) he

b) lo

c) olleh

d) hello

a) he

49.………..function will always return tuple of 3 elements.

a) index()

b) split()

c) partition()

d) strip()

c) partition()

50.What is the correct python code to display the last four characters of “Digital India”

a) str[-4:]

b) str[4:]

c) str[*str]

d) str[/4:]

a) str[-4:]

LIST:

51. Given the list L=[11,22,33,44,55], write the output of print(L[: :-1]).

a) [1,2,3,4,5]

b) [22,33,44,55]

c) [55,44,33,22,11]

d) Error in code

c) [55,44,33,22,11]

52. Which of the following can add an element at any index in the list?

a) insert( )

b) append( )

c) extend()

d) all of these

a) insert( )

53. Which of the following function will return a list containing all the words of the given string?

a) split()

b) index()

c) count()

d) list()

a) split()

54.Which of the following statements are True.

i) [1,2,3,4]>[4,5,6]

ii) [1,2,3,4]<[1,5,2,3]

iii) [1,2,3,4]>[1,2,0,3]

iv) [1,2,3,4]<[1,2,3,2]

a) i,ii,iv

b) i,iii,iv

c) i,ii,iii

d) Only iv

c) i,ii,iii

55. If l1=[20,30] l2=[20,30] l3=[‘20’,’30’] l4=[20.0,30.0] then which of the following statements will not return ‘False’:

i) >>>l1==l2

ii) >>>l4>l1

iii) >>>l1>l2

iv) >>> l2==l2

a) ii, iii

b) i,ii,iii

c) i,iii,iv

d) i,iv

d) i,iv

56.>>>l1=[10,20,30,40,50]

>>>l2=l1[1:4]

What will be the elements of list l2:

a) [10,30,50]

b) [20,30,40,50]

c) [10,20,30]

d) [20,30,40]

d) [20,30,40]

57.>>>l=[‘red’,’blue’]

>>>l = l + ‘yellow’

What will be the elements of list l:

a) [‘red’,’blue’,’yellow’]

b) [‘red’,’yellow’]

c) [‘red’,’blue’,’yellow’]

d) Error

d) Error

58.What will be the output of the following code:

>>>l=[1,2,3,4]

>>>m=[5,6,7,8]

>>>n=m+l

>>>print(n)

a) [1,2,3,5,6,7,8]

b) [1,2,3,4,5,6,7,8]

c) [1,2,3,4][5,6,7,8]

d) Error

b) [1,2,3,4,5,6,7,8]

59.What will be the output of the following code:

>>>l=[1,2,3,4]

>>>m=l*2

>>>n=m*2

>>>print(n)

a) [1,2,3,4,1,2,3,4,1,2,3,4]

b) [1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4]

c) [1,2,3,4][4,5,6,7]

d) [1,2,3,4]

b) [1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4]

60.Match the columns: if

>>l=list(‘computer’)

 Column A Column B 1 L[1:4] a. [‘t’,’e’,’r’] 2 L[3:] b. [‘o’,’m’,’p’] 3 L[-3:] c. [‘c’,’o’,’m’,’p’,’u’,’t’] 4 L[:-2] d. [‘p’,’u’,’t’,’e’,’r’]

a) 1-b,2-d,3-a,4-c

b) 1-c,2-b,3-a,4-d

c) 1-b,2-d,3-c,4-a

d) 1-d,2-a,3-c,4-b

a) 1-b,2-d,3-a,4-c

61. If a list is created as

>>>l=[1,2,3,’a’,[‘apple’,’green’],5,6,7,[‘red’,’orange’]] then what will be the output of the following statements:

>>>l[4][1]

a) ‘apple’

b) ‘green’

c) ‘red’

d) ‘orange’

b) ‘green’

62.>>>l[8][0][2]

a) ‘d’

b)  ‘e’

c) ‘r’

d) ‘o’

a) ‘d’

63.>>>l[-1]

a) [‘apple’,’green’]

b) [‘red’,’orange’]

c) [‘red’ ]

d) [’orange’]

c) [‘red’ ]

64.>>>len(l)

a) 10

b) 9

c) 8

d) 11

b) 9

65.What will be the output of the following code:

>>>l1=[1,2,3]

>>>l1.append([5,6])

>>>l1

a) [1,2,3,5,6]

b) [1,2,3,[5,6]]

c) [[5,6]]

d) [1,2,3,[5,6]]

d) [1,2,3,[5,6]]

66.What will be the output of the following code:

>>>l1=[1,2,3]

>>>l2=[5,6]

>>>l1.extend(l2)

>>>l1

a) [5,6,1,2,3]

b) [1,2,3,5,6]

c) [1,3,5]

d) [1,2,3,6]

b) [1,2,3,5,6]

67. What will be the output of the following code:

>>>l1=[1,2,3]

>>>l1.insert(2,25)

>>>l1

a) [1,2,3,25]

b) [1,25,2,3]

c) [1,2,25,3]

d) [25,1,2,3,6]

c) [1,2,25,3]

68. >>>l1=[10,20,30,40,50,60,10,20,10]

>>>l1.count(‘10’)

a) 3

b) 0

c) 2

d) 9

b) 0

69.Which operators can be used with list?

a) in

b) not in

c) both (i)&(ii)

d) Arithmetic operator only

c) both (i)&(ii)

70.Which of the following function will return the first occurrence of the specified element in a list.

a) sort()

b) value()

c) index()

d) sorted()

c) index()

### MCQ Tuples and Dictionary:

71. Which of the statement(s) is/are correct.

a) Python dictionary is an ordered collection of items.

b) Python dictionary is a mapping of unique keys to values

c) Dictionary is mutable.

d) All of these.

d) All of these.

72. ………function is used to convert a sequence data type into tuple.

a) List()

b) tuple()

c) TUPLE

d) tup()

b) tuple()

73. It tup=(20,30,40,50), which of the following is incorrect

a) print(tup[3])

b) tup[2]=55

c) print(max(tup))

d) print(len(tup))

b) tup[2]=55

74. Consider two tuples given below:

>>>tup1=(1,2,4,3)

>>>tup2=(1,2,3,4)

What will the following statement print(tup1<tup2)

a) True

b) False

c) Error

d) None of these

b) False

75. Which function returns the number of elements in the tuple

a) len( )

b) max( )

c) min( )

d) count( )

a) len( )

76. Which function is used to return a value for the given key.

a) len( )

b) get( )

c) keys( )

d) None of these

b) get( )

77.Keys of the dictionary must be

a) similar

b) unique

c) can be similar or unique

d) All of these

b) unique

78. Which of the following is correct to insert a single element in a tuple .

a) T=4

b) T=(4)

c) T(4,)

d) T=[4,]

c) T(4,)

79.Which of the following will delete key-value pair for key=’red’ form a dictionary D1

a) Delete D1(“red”)

b) del. D1(“red”)

c) del D1[“red”]

d) del D1

c) del D1[“red”]

80.Which function is used to remove all items form a particular dictionary.

a) clear( )

b) pop( )

c) delete

d) rem( )

a) clear( )

81.In dictionary the elements are accessed through

a) key

b) value

c) index

d) None of these

a) key

82.Which function will return key-value pairs of the dictionary

a) key( )

b) values( )

c) items( )

d) get( )

c) items( )

83.Elements in a tuple can be of ………….type.

a) Dissimilar

b) Similar

c) both i & ii

d) None of these

c) both i & ii

84.To create a dictionary , key-value pairs are separated by…………….

a) (;)

b) ( , )

c) (:)

d) ( / )

c) (:)

85.Which of the following statements are not correct:

i) An element in a dictionary is a combination of key-value pair

ii) A tuple is a mutable data type

iii) We can repeat a key in dictionary

iv) clear( ) function is used to deleted the dictionary.

a) i,ii,iii

b) ii,iii,iv

c) ii,iii,i

d) i,ii,iii,iv

b) ii,iii,iv

86.Which of the following statements are correct:

i) Lists can be used as keys in a dictionary

ii) A tuple cannot store list as an element

iii) We can use extend() function with tuple.

iv) We cannot delete a dictionary once created.

a) i,ii,iii

b) ii,iii,iv

c) ii,iii,i

d) None of these

d) None of these

87.Like lists, dictionaries are……………..which mean they can be changed.

a) Mutable

b) immutable

c) variable

d) None of these

a) Mutable

88.To create an empty dictionary , we use

a) d=[ ]

b) d =( )

c) d = {}

d) d= < >

c) d = {}

89.To create dictionary with no items , we use

a) Dict

b) dict( )

c) d = [ ]

d) None of these

b) dict( )

90.What will be the output

>>>d1={‘rohit’:56,”Raina”:99}

>>>print(“Raina” in d1)

a) True

b) False

c) No output

d) Error

a) True

91. Rahul has created the a tuple containing some numbers as

>>>t=(10,20,30,40)

now He want to add a new element 60 in the tuple, which statement he should use out of the given four.

a) >>>t+(60)

b) >>>t + 60

c)  >>>t + (60,)

d) >>>t + (‘60’)

c)  >>>t + (60,)

92. Rahul wants to delete all the elements from the tuple, which statement he should use

a) >>>del t

b) >>>t.clear()

c)  >>>t.remove()

d) >>>None of these

a) >>>del t

93.Rahul wants to display the last element of the tuple, which statement he should use

a) >>> t.display()

b) >>>t.pop()

c) >>>t[-1]

d) >>>t.last()

c) >>>t[-1]

94.Rahul wants to add a new tuple t1 to the tuple t, which statement he should use

a) >>>t+t1

c) >>>t*t1

d) None of these

a) >>>t+t1

95. Rahul has issued a statement after that the tuple t is replace with empty tuple, identify the statement he had issued out of the following:

a) >>> del t

b) >>>t= tuple()

c) >>>t=Tuple()

d) >>>delete t

b) >>>t= tuple()

96. Rahul wants to count that how many times the number 10 has come:

a) >>>t.count(10)

b) >>>t[10]

c) >>>count.t(10)

d) None of these

a) >>>t.count(10)

97. Rahul want to know that how many elements are there in the tuple t, which statement he should use out of the given four

a) >>>t.count()

b) >>>len(t)

c) >>>count(t)

d) >>>t.sum()

b) >>>len(t)

98.>>>t=(1,2,3,4)

Write the statement should be used to print the first three elements 3 times

a) >>>print(t*3)

b) >>>t*3

c)  >>>t[:3]*3

d) >>>t+t

c)  >>>t[:3]*3

99. Match the output with the statement given in column A with Column B.

 Column A Column B >>>tuple([10,20,30]) a. >>> (10,20,30) >>>(“Tea”,)* 3 b. >>> 2 >>>tuple(“Item”) c. >>> (‘Tea’, ‘Tea’, ‘Tea’) >>>print(len(tuple([1,2]))) d. >>> (‘I’, ‘t’, ‘e’, ‘m’)

a) 1-b,2-c,3-d,4-a

b) 1-a,2-c,3-d,4-b

c) 1-c,2-d,3-a,4-a

d) 1-d,2-a,3-b,4-c

b) 1-a,2-c,3-d,4-b

100. Write the output of the following code:

>>>d={‘name’:’rohan’,’dob’:’2002-03-11’,’Marks’:’98’}

>>>d1={‘name’:‘raj’)

>>>d1=d.copy()

>>>print(“d1 :”d1)

a) d1 : {‘name’: ‘rohan’, ‘dob’: ‘2002-03-11’, ‘Marks’: ’98’}

b) d1 = {‘name’: ‘rohan’, ‘dob’: ‘2002-03-11’, ‘Marks’: ’98’}

c) {‘name’: ‘rohan’, ‘dob’: ‘2002-03-11’, ‘Marks’: ’98’}

d) (d1 : {‘name’: ‘rohan’, ‘dob’: ‘2002-03-11’, ‘Marks’: ’98’})

a) d1 : {‘name’: ‘rohan’, ‘dob’: ‘2002-03-11’, ‘Marks’: ’98’}

#### By cbsepython

A complete solution for the students of class 9 to 12 having subject Information Technology (402), Computer Science (083). Explore our website for all the useful content as Topic wise notes, Solved QNA, MCQs, Projects and Quiz related to the latest syllabus.