Robotics & Artificial Intelligence

What are the rules to assign a variable in a Python code?

Python Funda

1 Like

Answer

The rules to assign a variable in a Python code are as follows:

  1. A variable may have any number of characters.
  2. A variable name cannot start with a number, but it can start with characters or an underscore (e.g., _rollnum).
  3. The underscore can be used in between the characters to separate the words of a variable name (e.g., reg_no).
  4. The variable names should be meaningful, which easily explains their purpose.
  5. Python is case sensitive. So, it treats uppercase and lowercase letters differently (e.g., Name and name are different variables).

Answered By

3 Likes


Related Questions