Test Series - python

Test Number 1/108

Q: Is Python case sensitive when dealing with identifiers?
A. yes
B. no
C. machine dependent
D. none of the mentioned
Solution: Case is always significant.
Q: What is the maximum possible length of an identifier?
A. 31 characters
B. 63 characters
C. 79 characters
D. none of the mentioned
Solution: Identifiers can be of any length.
Q: Which of the following is invalid?
A. _a = 1
B. __a = 1
C. __str__ = 1
D. none of the mentioned
Solution: All the statements will execute successfully but at the cost of reduced readability.
Q: Which of the following is an invalid variable?
A. my_string_1
B. 1st_string
C. foo
D. _
Solution: Variable names should not start with a number.
Q: 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
Solution: As Python has no concept of private variables, leading underscores are used to indicate variables that must not be accessed from outside the class.
Q: Which of the following is not a keyword?
A. eval
B. assert
C. nonlocal
D. pass
Solution: eval can be used as a variable.
Q: All keywords in Python are in _________
A. lower case
B. UPPER CASE
C. Capitalized
D. None of the mentioned
Solution: True, False and None are capitalized while the others are in lower case.
Q: 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
Solution: Variable names can be of any length.
Q: 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
Solution: Spaces are not allowed in variable names.
Q: Which of the following cannot be a variable?
A. __init__
B. in
C. it
D. on
Solution: in is a keyword.

You Have Score    /10