Which of the following is a valid variable name in Python?

Options

  • A. my-value
  • B. class
  • C. _my_value
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. _my_value

Detailed Explanation

Correct Answer: C — _my_value.

Explanation: Python identifiers may begin with a letter or underscore, but not a digit. A hyphen is an operator, and class is a reserved keyword. Therefore, _my_value is valid.