1). Is Python case sensitive when dealing with identifiers?
[A]yes
[B]no
[C]machine dependent
[D]none of the mentioned
Show Answer
Correct Answer: yes
Notes:
Answer: a
Explanation: Case is always significant while dealing with identifiers in python.
2). What is the maximum possible length of an identifier?
[A]31 characters
[B]63 characters
[C]79 characters
[D]none of the mentioned
Show Answer
Correct Answer: none of the mentioned
Notes:
Answer: d
Explanation: Identifiers can be of any length.
3). Which of the following is invalid?
[A]_a = 1
[B]__a = 1
[C]__str__ = 1
[D]none of the mentioned
Show Answer
Correct Answer: none of the mentioned
Notes:
Answer: d
Explanation: All the statements will execute successfully but at the cost of reduced readability.
4). Which of the following is an invalid variable?
[A]my_string_1
[B]1st_string
[C]foo
[D] _
Show Answer
Correct Answer: 1st_string
Notes:
Answer: b
Explanation: Variable names should not start with a number.
5). 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
Show Answer
Correct Answer: they are used to indicate a private variables of a class
Notes:
Answer: a
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.
6). Which of the following is not a keyword?
[A]eval
[B]assert
[C]nonlocal
[D]pass
Show Answer
Correct Answer: eval
Notes:
Answer: a
Explanation: eval can be used as a variable.
7). All keywords in Python are in _________
[A]lower case
[B]UPPER CASE
[C]Capitalized
[D]None of the mentioned
Show Answer
Correct Answer: None of the mentioned
Notes:
Answer: d
Explanation: True, False and None are capitalized while the others are in lower case.
8). Which of the following is true for variable names in Python?
[A]unlimited length
[B]all private members must have leading and trailing underscores
[C]underscore and ampersand are the only two special characters allowed
[D]none of the mentioned
Show Answer
Correct Answer: unlimited length
Notes:
Answer: a
Explanation: Variable names can be of any length.
9). 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
Show Answer
Correct Answer: a b c = 1000 2000 3000
Notes:
Answer: b
Explanation: Spaces are not allowed in variable names.
10). Which of the following cannot be a variable?
[A]__init__
[B]in
[C]it
[D]on
Show Answer
Correct Answer: in
Notes:
Answer: b
Explanation: in is a keyword.