#5 - Variables - A box to our data

Variables

We just now wrote our first program but we will rarely output such hard-coded text. Mostly we output some data that is stored in a variable. So now let's learn about Variables.


What are Variables?

Variables are like containers containing a specific value that can be accessed anywhere in the code using the variable name. A variable name must start with a letter or an underscore( _ ) and they are case-sensitive and can only contain alpha-numeric characters and underscores. Use an equal sign ( = ) to assign a variable.

code:-





output:-

We are learning Python.


How to reassign a value to a Variable?

It's too easy to reassign a value to a variable, simply again use the same method of assigning the value as you did last time.

Code:-






Output:-





How to pass value from one variable to another with any change?

To do so, all you have to do is put the variable name at the place of value without quotation marks.

Code:-









Output:-
5

Now learn yourself

There can be many different things that can be done with variables. Take your time to do different interesting operations with it and share them in the comments.



WHAT COMING NEXT?

Now, let's learn some maths. Not the hard one but just the basic operations.

Arithmetic operators

Comments

Post a Comment

Popular posts from this blog

Comments

#1- Let's Learn Python In the least possible time

#9 - String Concatenation