arrow
arrow
arrow
Which of the following is a valid identifier in Python?
Question



Which of the following is a valid identifier in Python?

A.

1stVariable

B.

variable-name

C.

variable_name

D.

for

E.

variable@name

Correct option is C

In Python, a valid identifier is a name used to identify a variable, function, or other object. The identifier variable_name is valid because it follows all Python naming conventions:
· It begins with a letter or underscore (_).
· It only contains letters, digits, or underscores.
· It does not use any reserved keywords (like for, if, etc.).
· It does not contain special characters like @, -, or spaces.
Important Key Points:
1. Python identifiers:
· Must begin with a letter (A-Z, a-z) or an underscore _.
· Can contain alphanumeric characters and underscores (A-Z, a-z, 0-9, _).
· Are case-sensitive (variable and Variable are different).
· Cannot be Python keywords or contain special characters like - or @.
2. Examples of valid identifiers:
· _variable
· variable_name
· var123
3. Examples of invalid identifiers:
· 1stVariable (starts with a digit).
· variable-name (contains a hyphen).
· variable@name (contains @).
· for (reserved keyword).
Knowledge Booster:
· 1stVariable: Invalid because it starts with a digit, which is not allowed in Python identifiers.
· variable-name: Invalid because it contains a hyphen (-), which is not a permitted character.
· for: Invalid because it is a reserved keyword in Python. Reserved keywords cannot be used as identifiers.
· variable@name: Invalid because it contains the special character @, which is not allowed in identifiers.

Free Tests

Free
Must Attempt
Video Solutions

RBI Assistant Pre 2026 Full Mock Test -01

languageIcon English
  • pdpQsnIcon100 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt
Video Solutions

RBI Asst Prelims 2026 : Reasoning Section Test 01

languageIcon English
  • pdpQsnIcon35 Questions
  • pdpsheetsIcon35 Marks
  • timerIcon20 Mins
languageIcon English
Free
Must Attempt
Video Solutions

RBI Office Attendant 2026 Full Mock Test - 01

languageIcon English
  • pdpQsnIcon120 Questions
  • pdpsheetsIcon120 Marks
  • timerIcon90 Mins
languageIcon English
test-prime-package

Access ‘IBPS SO IT Officer’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
354k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow