Robotics & Artificial Intelligence
What are the rules to assign a variable in a Python code?
Python Funda
2 Likes
Answer
The rules to assign a variable in a Python code are as follows:
- A variable may have any number of characters.
- A variable name cannot start with a number, but it can start with characters or an underscore (e.g.,
_rollnum). - The underscore can be used in between the characters to separate the words of a variable name (e.g.,
reg_no). - The variable names should be meaningful, which easily explains their purpose.
- Python is case sensitive. So, it treats uppercase and lowercase letters differently (e.g.,
Nameandnameare different variables).
Answered By
2 Likes
Related Questions
Explain the following data types:
(a) String
(b) List
(c) Tuple
(d) Dictionary
What is meant by Python Sets? Explain with the help of an example.
Explain each of the following with an example:
(i) Implicit type conversion
(ii) Explicit type conversion
How will you assign multiple objects to multiple variables? Explain with the help of an example.