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

Group, if, int, total marks, S.l., volume, tot_strength, #tag, tag$, 9a


Answer :-

Invalid variable :- if , total marks, S.I., #tag, tag$, 9a

Reason :

if: "if" is a reserved keyword in Python and cannot be used as a variable name. It is used for conditional statements.

total marks: Variable names cannot contain space (" ") as it is not valid character. You can only use letters, numbers, and underscores.

S.l.: Variable names cannot contain periods (".") as it is not valid character. You can only use letters, numbers, and underscores.

#tag: Variable names cannot start with a hashtag symbol (#). It is used to represent comments in Python.

tag$: Variable names cannot contain a dollar sign ($) as it is not a valid character. Only letters, numbers, and underscores are allowed.

9a: Variable names cannot start with a number. They can contain numbers as long as they are not the first character.

5 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post