Professional Documents
Culture Documents
com 91+9823340767
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
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
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