Variables are saved memory areas to store values. This implies that once you make a variable you save a few spaces in memory.
A Python variable is a typical title that is a reference to an object. The information itself is still contained inside the object. Once an object is relegated to a variable, you’ll refer to the question by that title. It is the basic unit of storage in a program.
Variable Assignment:
To assign any value to the python variables use a single equal sign ( = ). Variable is the name attached to the object. To create a variable just assign a value to it and then it can be used easily.
a = 10 # Assigning integer b = 109.0 # Assigning floating point print (a) print (b)
Rules for Naming Variable:
There are some rules to name any python variable. some are given as below,
- A variable name must start with a letter or the underscore character.
- Variable can be of any length.
- A variable name cannot start with a number.
- Variable names are case-sensitive.
- In a variable name, Whitespace is not allowed.
- A variable name can only contain underscores and alphanumeric characters.
- Reserved words are not allowed as variable names.