Variables And Constants

Variables And Constants

Table of contents

Namaste coders!

In this article, we will learn about variables and containers.

Variables

It is a memory location that store Literal value. This location must be referred by a valid identifier. Variables are like a container in which we store data.

22.PNG

Let's discuss this in layman's language. Like in our kitchen we have different containers of different types and sizes to store different items. Similarly, in programming, we create variables ( which are containers) that allow us to store data in memory. We can reuse these variables in the program.

A valid variable name follows all the rules applied to an identifier.

18.PNG

We can change the value of a once-defined variable.

20.PNG

As python is a dynamically typed language, we do not need to explicitly mention the datatype of data stored in that variable. Python is smart enough to know the datatype of the data stored in the variable.

19.PNG

Constants

These are the variables whose value cannot be changed. Thus, Python doesn’t have any syntax for constants. But as a convention, we use uppercase naming to say it is a constant. Constants are used when we do not need to change the value.

21.PNG

The End

I hope you enjoyed the article and had a good learning experience.

Follow for more articles and keep sharing👩

Keep coding

Linkedin

hashnode blogs

Did you find this article valuable?

Support akshita garg by becoming a sponsor. Any amount is appreciated!