Site icon CBSECS

Identifiers in Python

Identifiers in Python

Python Identifiers Quiz | cbsecs.in

Python Identifiers Quiz

20 Questions: 10 Rules | 10 Examples

Part 1: Theoretical Rules

1. Which character set does Python recognize for its identifiers?
  • ASCII only
  • Unicode
  • EBCDIC
2. An identifier cannot start with which of the following?
  • An underscore (_)
  • A letter (A-Z or a-z)
  • A digit (0-9)
3. How does Python treat identifiers ‘Value’ and ‘value’?
  • As identical
  • As different (Case Sensitive)
  • Only ‘value’ is valid
4. Which of these symbols is allowed inside an identifier?
  • Hyphen (-)
  • Underscore (_)
  • Dollar Sign ($)
5. What is the limit on the length of a Python identifier?
  • 31 Characters
  • 255 Characters
  • Unlimited length
6. Can a ‘Keyword’ like ‘while’ be used as a variable name?
  • Yes, always
  • No, they are reserved
  • Yes, if in uppercase
7. Are spaces allowed inside a single identifier name?
  • No
  • Yes, if quoted
8. Which of these can be an identifier?
  • Variable names only
  • Variable, Function, and Class names
  • Literals
9. What category do symbols like [], {}, and () fall into?
  • Identifiers
  • Punctuators
  • Literals
10. Why is starting with a digit illegal?
  • It uses more RAM
  • To prevent confusion with numeric literals

Part 2: Examples & Validation

11. Which of these is a VALID identifier?
  • 2nd_var
  • _total_score
  • total-score
12. Identify the INVALID identifier:
  • True_Val
  • True
  • TRUE
13. Which of the following is invalid because of a punctuator?
  • roll_no
  • roll.no
  • rollNo
14. Is ‘____’ (multiple underscores) a valid identifier?
  • Yes
  • No
15. Identify the VALID identifier:
  • my$price
  • data_2
  • class
16. Which of these is invalid due to naming rules?
  • else
  • Else
  • ELSE
17. Which identifier is correctly formed?
  • student name
  • _student_name
  • student@name
18. Identify the valid identifier using digits:
  • 9lives
  • lives9
  • lives-9
19. Which of these can be used as a name?
  • yield
  • yield_value
20. What is the output of choosing ‘None’ as a variable name?
  • Success
  • SyntaxError
CERTIFICATE OF ACHIEVEMENT

This award is presented to

Student Name

for completing the Python Identifier Naming Assessment

Score: 0 / 20
Exit mobile version