Is Python case sensitive when dealing with identifiers?
a) yes
b) no
c) machine dependent
d) none of the mentioned
Explanation: Case is always significant while dealing with identifiers in python.
What is the maximum possible length of an identifier?
a) 31 characters
b) 63 characters
c) 79 characters
d) none of these
Explanation: Identifiers can be of any length.
Which of the following is invalid?
a) _a = 1
b) __a = 1
c) __str__ = 1
d) none of these
Explanation: All the statements will execute successfully but at the cost of reduced readability.
Which of the following is an invalid variable?
a) my_string_1
b) 1st_string
c) foo
d) _
Explanation: Variable names should not start with a number.
Why are local variable names beginning with an underscore discouraged?
a) they are used to indicate a private variables of a class
b) they confuse the interpreter
c) they are used to indicate global variables
d) they slow down execution
Explanation: As Python has no concept of private variables, leading underscores are used to indicate variables that must not be accessed from outside the class.
Which of the following is not a keyword?
a) eval
b) assert
c) nonlocal
d) pass
Explanation: eval can be used as a variable.