Skip to content
Exercises · Q1

Q.Which of the following identifier names are invalid and why?
i. Serial_no.
ii. 1st_Room
iii. Hundred$
iv. Total Marks
v. Total_Marks
vi. total-Marks
vii. _Percentage
viii. True

Tripura TbseTextbookSubjective· 3mImportance★★★★★est
57% · 28/49 Questions
✓ Free question

Six of the eight names break Python's identifier rules — only Total_Marks and _Percentage are valid.

The idea — identifier validity rules. A Python identifier

  1. may contain only letters (A–Z, a–z), digits (0–9) and the underscore;
  2. must not begin with a digit;
  3. must not be a keyword (True, if, for, …);
  4. allows no spaces or special symbols (dot, hyphen, the dollar symbol, etc.).

Checking each name against those rules:

#IdentifierValid?Rule broken / satisfied
iSerial_no.Invalidends with a dot — the period is not allowed inside an identifier (it is the attribute-access operator)
ii1st_RoomInvalidstarts with a digit
iiiHundred followed by the dollar symbolInvalidthe dollar sign is a special symbol, never allowed in identifiers
ivTotal MarksInvalidcontains a space — Python would read two separate names
vTotal_MarksValidletters and underscore only
vitotal-MarksInvalidthe hyphen is the subtraction operator; Python would parse total - Marks
vii_PercentageValidan identifier may begin with an underscore
viiiTrueInvalidTrue is a reserved keyword (a Boolean literal); keywords can never be identifiers
Tip

A quick machine check: "Total_Marks".isidentifier() returns True, and keyword.iskeyword("True") returns True — together they encode exactly these rules.

✓Final answer

Invalid: (i) Serial_no. — dot; (ii) 1st_Room — leading digit; (iii) the dollar-sign name — special symbol; (iv) Total Marks — space; (vi) total-Marks — hyphen; (viii) True — keyword. Valid: (v) Total_Marks and (vii) _Percentage.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.