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

Study for the PCEP Certified Entry-Level Python Programmer Exam. Access multiple choice questions and detailed explanations to enhance your learning. Prepare effectively for your certification!

In Python, variable names must adhere to specific rules to be considered valid. A valid variable name must start with a letter (a-z, A-Z) or an underscore (_), and can be followed by letters, digits (0-9), or underscores.

The variable name containing "2nd_var" begins with a digit, which is not permitted in Python. This is why it is identified as an invalid variable name.

The other options start with a letter or an underscore and follow the rules for valid variable naming. "var_name" contains an underscore and is valid, "varName" follows camel case conventions and is also valid, and "VAR123" begins with letters and includes numbers, making it a valid identifier too. Thus, the option "2nd_var" is the only one that does not meet the criteria for a valid variable name in Python.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy