KnowledgeBoat Logo
|

Informatics Practices

Identify invalid variable names from the following, giving reason for each:

Group, if, total marks, S.I., volume, tot_strength, #tag, tag$\text{\textdollar}, 9a

Python Funda

4 Likes

Answer

  1. Group — It is a valid variable name.
  2. if — It is a reserved keyword in Python and cannot be used as a variable name.
  3. total marks — It contains a space, which is not allowed in variable names.
  4. S.I. — It contains a dot (.), which is not allowed in variable names.
  5. volume — It is a valid variable name.
  6. tot_strength — It is a valid variable name.
  7. #tag — It starts with a hash (#), which is not allowed in variable names.
  8. tag$\text{\textdollar} — It contains a dollar sign ($\text{\textdollar}), which is not allowed in variable names.
  9. 9a — It starts with a number, which is not allowed in variable names.

Answered By

2 Likes


Related Questions