Variable declaration in python
Variable declaration in python
![]() |
| Image credits: Google |
Variable is are used to store values in it.
You can assume variable is a like a box and value is which you can store in the box
Rules to declare variables and indentifiers
Identifiers - Names to given variables, classes, methods etc...
1. Identifiers cannot be a keyword.
2. Identifiers are case-sensitive.
3. It can have a sequence of letters and digits. However, it must begin with a letter or _. The first letter of an identifier cannot be a digit.
4. It's a convention to start an identifier with a letter rather _.
5. Whitespaces are not allowed.
6. We cannot use special symbols like !, @, #, $, and so on.
Declaring a variable in python
Declaring variable a which a is the variable name and value 56 is stored in it
And we don't need tell explicitly data type of our variable which will store that data type value
Python will implicitly do it
Output:
int means integer
We can also change value in our variable
Output:
We can also restore different data type value in our variable
Output:
int means integer data type
str means string data type
Image credits: Programiz
Disclaimer: All the above images used in this blog are owned by respective owners. Please contact me for any removal of images. No copyright infringement







Comments
Post a Comment