Which of these is an acceptable variable name in Python?

Responses

3rdScore

thirdScore

Third Score

3rd Score

1 answer

In Python, variable names must follow certain rules. They must start with a letter (a-z, A-Z) or an underscore (_), and they can be followed by letters, digits (0-9), or underscores. Variable names cannot contain spaces or start with a digit.

Given your options, the acceptable variable name is:

  • thirdScore

The other options are not valid variable names because:

  • 3rdScore: Starts with a digit.
  • Third Score: Contains a space.
  • 3rd Score: Contains a space and starts with a digit.