Correct option is A
In Python,
identifiers are names used to identify variables, functions, classes, or other objects. The rules for valid identifiers in Python are:
1. An identifier must start with a
letter (A-Z or a-z) or an
underscore (_).
2. The rest of the identifier can contain letters, digits (0-9), and underscores.
3. Identifiers cannot start with a digit.
Given the options:
·
(a) 1stName: This is
invalid because the identifier starts with a
digit (1), which is not allowed in Python.
·
(b) Name1: This is
valid because it starts with a letter and contains a digit, which is allowed.
·
(c) Name_1: This is
valid because it starts with a letter and contains an underscore and a digit, which are allowed.
·
(d) FirstName: This is
valid because it starts with a letter and contains only letters.
Important Key Points:
1.
Identifiers cannot start with digits. They can only start with letters or underscores.
2.
Underscores and digits are allowed after the first character.
Knowledge Booster:
· Identifiers like
_variable are valid, as the underscore is considered a valid starting character.
· Python identifiers are case-sensitive, meaning
name and
Name are treated as different identifiers.