|

Variables | Python tutorial in Sinhala Learn Basic of Python Programming #5 Video

Watch the video before you read this.

Let`s talk about Variables. So we use Pycharm software for coding. What are variables ? 

Ex : x = 2 + 5

Now you can see the equation x = 2 + 5  In here , the variable is given as ” x “. That’s it.

Let’s see some best examples to identify about variables. First example is, 

x = 2
y = 5
print(x)

Here, you can see I take two variables as “x” and “y” Then I substitute 2 and 5 for that two variables. Next I print “x” The output is given as 2. I only printed x so the output is 2

Let`s move to next example,

p = (x + y)
print(p)

Now you can see the answer like this,

7

Process finished with exit code 0

Here, I took “p” as the variable. Then type p = ( x + y), then print (p) So the output is 7 Before I substituted 2 and 5 for “x” and “y” So that the answer is 7

Let`s look at that example in another way,

x = 2
y = 5
print(x + y)

Now you can see the answer below,

7

Process finished with exit code 0

Again I take ” x ” and ” y ” as variables and substitute  2 and 5 I print “x” and “y” The output is 7.

The next important thing is If you replace the original variable with a new value, the new value will replace the previous value.

Here you can see the example,

x = 2
y = 5
x = 5
print(x)

Now you can see the answer,

5

Process finished with exit code 0

So that`s all We talked about in this video I hope you will learn anything from this video.

Subscribe My Channel for watch More Educational Contents.

Thank You.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *