You are on page 1of 9

LinearIndiaEducation@gmail.

com 91+9823340767

Internal exam is having total 30 questions for 30 marks.


Total time is around 30 minutes.
In this document, 20 MCQ for your reference, every question is having the
answer for your reference.

List of questions
1. Who is Python's benevolent dictator for life?
a) Guido van Rossum
b) Wick van Rossum
c) Rasmus Lerdorf
d) Niene Stom
Answer is A ( Guido van Rossum)
Guido van Rossum is the founder of Python hence this title is given to him.
----------------------------------------------------------------------------------------------
2. The id() function can be used to get the data type of any object.
a) True
b) False
Answer is False because id() function is used to get the address of any object
And type() is used to get the data type of any object
------------------------------------------------------------------------------------------------
3. All keywords in Python are Upper Case
a) True
b) False
Answer is False.
All keywords in Python are lowercase except True, False and None because
they are value.
-----------------------------------------------------------------------------------------------
LinearIndiaEducation@gmail.com 91+9823340767

4. {} brackets are used to define a block of code in Python language.


a) True
b) False
Answer is False, In Python, Indentation is used to define a block of code.
5. class keyword is used for function in Python language?
a)True
b)False
Answer is False, def keyword is used for function in Python language.
----------------------------------------------------------------------------------------
6.Which of the following character is used to give single-line comments in
Python?
a) //
b) #
c) !
d) /*
Answer is b, # is used to give single line comment in Python
--------------------------------------------------------------------------------------
7.What will be the output of the following Python code snippet
value=8
value>>1
a) 16
b) 4
Answer is 4, Binary Number System
LinearIndiaEducation@gmail.com 91+9823340767

There are two operators Right Shift Operator >> and Left Shift Operator <<.
Binary representation of 8 is 1000, In case of right shift operator, given bit is
shifted by 1 position to the right hence it becomes 0100 i.e. 4
In case of left shift operator, given bit is shifted by 1 position to the left hence
it becomes 10000 i.e. 16
8.The / operator returns the ___.
a)Quotient
b)Floor Division
c)Remainder
d)None of the mentioned above
Answer is A
Remember the list of Arithmetic operators in Python.

------------------------------------------------------------------------------------------------
LinearIndiaEducation@gmail.com 91+9823340767

9.What will be the output of the following Python code?


T=(10,10,10,20,"Marks",0,99)
print(len(T))
a)7
b)5
Answer is 7.
Duplicate items are allowed in List and Tuple. There are total 7 items in the
Tuple.
---------------------------------------------------------------------------------------------
10.What will be the output of the following Python code?
T=[90,80,70,60,50,40,30,20,10]
print(T[0:3])
a)[10,20,30,40]
b)[90,80,70]
c)[90,80,70,60]
d)None of the above
Answer is B i.e. 90,80,70
Remember slicing operation
LinearIndiaEducation@gmail.com 91+9823340767

T[0:3]=> O is the start, 3 is the stop and 1 is the step by default.


Hence [90,80,70]
11.What will be the output of the following Python code?
txt="Welcome"
print(txt[::-1])
a)emocleW
b)Welcome
c)TypeError
d)None of the above
Answer is A.
This is again related with slicing operation.
In order to reverse the string, list and tuple, we can just write [ : : -1]
------------------------------------------------------------------------------------------------
12.What will be the output of the following code snippet?
print(9**2)
a)18
b)81
c)None of the above
Answer is B.
Remember the list of Arithmetic operators given above.
** operator is used for Exponential operation. Here, 9 is the base and 2 is the
exponent hence output is 81
-------------------------------------------------------------------------------------------------
LinearIndiaEducation@gmail.com 91+9823340767

13.What will be the datatype of the var in the below code snippet?
xyz = 35.23
print(type(var))
xyz = "welcome"
print(type(var))
a) int and str
b) int and int
c) str and str
d) float and str
Answer is D
type() is used to find the type of any given value. Type of 35.23 is the float
and “welcome” is the str hence output is float and str
-------------------------------------------------------------------------------------------------
14.What will be the output of the following code snippet?
L = [100, 110, 120]
T = tuple(L)
T[0] = 2
print(T)

a) 100
b) Type Error
c) Syntax Error
d) (100,110,120)
Answer is B, Type Error
Here, List L is converted into Tuple T and then, trying to replace the value of
0th location i.e. 110 by 2. This operation is not allowed for Tuple as Tuple is
Immutable hence Type Error
-----------------------------------------------------------------------------------------------
LinearIndiaEducation@gmail.com 91+9823340767

15.What error will occur when you execute the following code?
name=’Python’
print(version)
a)Type Error
b)Syntax Error
c)Name Error
d)Key Error
Answer is C , Name Error
In this example, variable version is directly used in the print() function
without having any value hence there will be error Name Error
----------------------------------------------------------------------------------------------
16.What will be the output of the following code snippet?
L=[10,20,30,40]
avg = 67.11
print(L+avg)
a) [10,20,30,40,67.11]
b) Syntax Error
c) Type Error: can only concatenate list (not "float") to list
d) None of the above
Answer is C , Type Error as both are different types i..e List and Float
+ operator can be used in between two similar type of following objects:
• Strings
• List
• Tuple
But + operator can not be used in between two different type of objects like
String and Number or List and Number or Tuple and Number
------------------------------------------------------------------------------------------------
LinearIndiaEducation@gmail.com 91+9823340767

17. The output of this Python code would be:


d={"p1":[10,"Sachin Tendulkar",65],"p2":[5,"Rahul Dravid",78]}
d.clear()
a) clear method does not exist for dictionary
b) clear would delete all the keys in dictionary
c) clear would delete the entire dictionary
d) clear would delete all key-value pairs for dictionary
Answer is D as it just delete all the key-value pairs.
There are 3 methods can be used for dictionary to delete the elements
• pop() : used to delete the individual element
• clear() : used to delete all the key-value paris
• del : used to delete the entire dictionary at one go
----------------------------------------------------------------------------------------------
18.What will be the output of the following code snippet?
T=("Python",3.11)
lang, version=T
print(version)
a) ("Python",3.11)
b) Python
c) 3.11
d) Type Error
Answer is C.
There are two mechanisms, Packing and Unpacking in case of Tuple.
Unpacking is used in this example as given tuple T is having 2 items i.e. Python
and 3.11 hence both variable is initialized as below
• lang=”Python”
• version = 3.11
LinearIndiaEducation@gmail.com 91+9823340767

19.What will be the output of the following code snippet?


fruits=['apple','Mango','Orange']
fruits.sort()
print(fruits)

a) ['Mango', 'Orange', 'apple']


b) ['apple', 'mango', ‘orange']
c) ['Apple', Mango', ‘Orange']
d) None of the above
Answer is A Mango, Orange, apple
ASCII range for upper case is 65 to 90 and lower case is 97 to 122.
By-default sorting order is ASCENDING.
Here ASCII value of ‘M’ is 77, ‘O’ is 79 and ‘a’ is 97
Hence 77,79,97 i.e. Mango, Orange, apple
------------------------------------------------------------------------------------------
20.What will be the output of the following code snippet?
S = {10,20,30}
print(S*2)
a) {10,20,30},{10,20,30}
b) {10,20,30,10,20,30}
c) TypeError
d) None of the above
Answer is C , Type Error
* operator is used for repetitions of given String, List and Tuple because these
3 data structures supports the duplicate data.
But Dictionary and Set do not support the duplicate data hence TyepError is
generated for this code snippet.

You might also like