Question 1 Report
Which of the following is a valid variable name in Python?
Python enforces a small set of rules for naming variables. A valid name must start with a letter or an underscore, may be followed by any combination of letters, digits, and underscores, and must not contain spaces or symbols such as \(\$\) or a hyphen, since Python would interpret a hyphen as a subtraction operator.
Checking each proposed name against these rules: one name is rejected because it contains the symbol \(\$\), which is not permitted in Python identifiers; another is rejected because a hyphen inside a name would be read as subtraction; and another is rejected because it starts with a digit, which Python does not allow since a name beginning with a number could be confused with a numeric literal. The remaining name uses only letters and an underscore and begins with a letter, satisfying every rule for a valid identifier.
When checking whether a variable name is valid in Python, look first at its first character, since that single check eliminates any name starting with a digit, and then scan the rest for forbidden symbols like \(\$\) or a hyphen.
Everything you need to excel in your exams