Sunday, June 7, 2020

Python Variables

A variable is a named location used to store data in the memory. It is helpful to think of variables as a container that holds data that can be changed later in the program. For example,
number = 10
Here, we have created a variable named number. We have assigned the value 10 to the variable.
You can think of variables as a bag to store books in it and that book can be replaced at any time.
number = 10
number = 1.1
Initially, the value of number was 10. Later, it was changed to 1.1.
Note: In Python, we don't actually assign values to the variables. Instead, Python gives the reference of the object(value) to the variable.

No comments:

Post a Comment