Which one of the following would be an illegal variable name


You need to follow some rules when deciding on a name for your variables. First, the name must start with a letter or an underscore. Second, after the first character, you can use letters, numbers, and underscores. Third, there are a few words that you can’t use as variable names because they are reserved for other things in Python. For example, you can’t use “print” as a variable name because “print” is a keyword in Python that is used to print information to the screen.

What is an illegal variable name?

There are a few different rules for creating legal variable names, but the main ones are that the name must start with a letter or underscore and it can contain only letters, numbers, or underscores.

Examples of illegal variable names

There are a few rules to follow when choosing a variable name in most programming languages:

-You can usually use letters and numbers, but some punctuation marks are not allowed.
-Variable names can’t be just a number (e.g. 7, 1234).
-Most languages don’t allow spaces in variable names, so you’ll have to use underscores instead (e.g. my_variable).
-Variable names can’t be the same as keywords in the programming language (e.g. int, for, class).
-In some languages, variable names have to start with a letter (e.g. PHP, Javascript) while others allow variables to start with any character (e.g. Perl, Ruby).

Why are illegal variable names not allowed?

Illegal variable names are not allowed because they can cause errors in your code. For example, if you use a variable name that is already being used by another part of your code, your code will not run correctly. Additionally, some languages do not allow certain characters in variable names, so using those characters would also cause an error.

How to choose a legal variable name

There are a few basic rules to follow when choosing a legal variable name:

-The name can consist of letters, numbers, and the underscore character.
-The name cannot begin with a number.
-The name cannot be a keyword in the language (e.g., int, float, if, else, etc.).
-The name cannot contain spaces.


In some languages, you can start a variable name with a number, but in JavaScript, this is not allowed. Also, there are certain words that you cannot use as variable names because they are reserved for other purposes. In JavaScript, these words are called keywords, and they include things like “for”, “while”, “do”, etc.

Leave a Reply

Your email address will not be published.