Q 1. Is Python case sensitive when dealing with identifiers?
A. machine dependent
B. no
C. yes
D. none of the mentioned
Show Answer
Answer:-C. yesExplanation
Explanation:- Case is always significant while dealing with identifiers in python.Q 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
Answer:-D. none of the mentionedExplanation
Explanation:- Identifiers can be of any length.Q 3. Which of the following is invalid?
A. _a = 1
B. __a = 1
C. __str__ = 1
D. none of the mentioned
Show Answer
Answer:-D. none of the mentionedExplanation
Explanation:- All the statements will execute successfully but at the cost of reduced readability.Q 4. Which of the following is an invalid variable?
A. 1st_string
B. my_string_1
C. foo
D. _
Show Answer
Answer:-A. 1st_stringExplanation
Explanation:- Variable names should not start with a number.Q 5. Why are local variable names beginning with an underscore discouraged?
A. they confuse the interpreter
B. they are used to indicate a private variables of a class
C. they are used to indicate global variables
D. they slow down execution
Show Answer
Answer:-B. they are used to indicate a private variables of a classExplanation
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.Q 6. Which of the following is not a keyword?
A. eval
B. assert
C. nonlocal
D. pass
Show Answer
Answer:-A. evalExplanation
Explanation:- eval can be used as a variable.Q 7. All keywords in Python are in _________
A. lower case
B. UPPER CASE
C. Capitalized
D. None of the mentioned
Show Answer
Answer:-D. None of the mentionedExplanation
Explanation: True, False and None are capitalized while the others are in lower case.Q 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
Answer:-A. unlimited lengthExplanation
Variable names can be of any length.Q 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
Answer:-C. a b c = 1000 2000 3000Explanation
Explanation:- Spaces are not allowed in variable names.Q 10. Which of the following cannot be a variable?
A. __init__
B. in
C. it
D. on
Leave a Reply