filmov
tv
Lists and variables[Understanding references in python]

Показать описание
This video explains about Programming in Python with Examples. It helps you Understand References in Python.
In this video we’re going to talk about lists and variable. In variables we’re going to Understand References in Python
This is Chennai Brothers.
References are variables in python. In python a variable can bind to primitives or other complex things. For the sake of this video we are only going to bind it with the primitives.
When we assign a variable to a number the number is now bonded with that variable. So if we want to create a copy of that variable to store it we can’t just say assign this variable to that variable or assign this variable to that variable. This is because if we wanted to change just one both will change since they are bonded together. An example is shown in video. That example would be wrong because they are both not bonded independent. X is bonded to [1,2,3]. Y is bonded to x. So, if we were to change X, Y would change. Another example is shown in video
So let’s see an example.
Here x is assigned to the list 1,2,3. We say assign x to y. and then the append function which adds a primitive to the end of the list. Now I say add ‘hi’ to y. Then I said to print x. Most beginners would except it print[1,2,3]
But we know it will print[1,2,3,hi]
So let’s try it just in case
And it is still right
Please let me know what topics in python should I cover in my next video in the comments section below. This is the end of this video. Thank you for watching my video, please like and share and subscribe to our videos. Have a good day.
See you soon with a brand-new python video.
In this video we’re going to talk about lists and variable. In variables we’re going to Understand References in Python
This is Chennai Brothers.
References are variables in python. In python a variable can bind to primitives or other complex things. For the sake of this video we are only going to bind it with the primitives.
When we assign a variable to a number the number is now bonded with that variable. So if we want to create a copy of that variable to store it we can’t just say assign this variable to that variable or assign this variable to that variable. This is because if we wanted to change just one both will change since they are bonded together. An example is shown in video. That example would be wrong because they are both not bonded independent. X is bonded to [1,2,3]. Y is bonded to x. So, if we were to change X, Y would change. Another example is shown in video
So let’s see an example.
Here x is assigned to the list 1,2,3. We say assign x to y. and then the append function which adds a primitive to the end of the list. Now I say add ‘hi’ to y. Then I said to print x. Most beginners would except it print[1,2,3]
But we know it will print[1,2,3,hi]
So let’s try it just in case
And it is still right
Please let me know what topics in python should I cover in my next video in the comments section below. This is the end of this video. Thank you for watching my video, please like and share and subscribe to our videos. Have a good day.
See you soon with a brand-new python video.