KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

In Python, a variable is used to store data that can change during program execution. Variables have certain rules for naming, including starting with a letter or an underscore and being case-sensitive.

What are the rules for naming variables in Python?

Getting Started

2 Likes

Answer

The rules for naming variables in Python are as follows:

  • A variable name must start with a letter (a–z or A–Z) or an underscore (_).
  • It cannot start with a digit.
  • A variable name can contain letters, digits, and underscores only.
  • Special characters such as @, #, $, %, etc., are not allowed.
  • Variable names are case-sensitive.
  • Keywords reserved by Python cannot be used as variable names.

Answered By

1 Like


Related Questions