14.4k views
3 votes
Which of the following are valid python variable names?

a. 4Cube
b. Feb1.4
c. cityState
d. Cannot be determined.
e. Cube4
f. City State
g. City State

1 Answer

7 votes

Final answer:

Valid Python variable names cannot start with a digit and should not contain spaces or special characters.

Step-by-step explanation:

Variable names in Python must adhere to certain rules. They can contain letters (both uppercase and lowercase), digits, and underscores, but cannot start with a digit. They should also not include any special characters or spaces.

Based on these rules, the valid variable names in the given options are:

  • b. Feb1
  • c. cityState
  • e. Cube4
  • f. CityState
  • g. CityState

The variable names not allowed are:

  • a. 4Cube - Starts with a digit
  • d. Cannot be determined - Contains spaces

User Chribsen
by
8.5k points