#52 Python Tutorial for Beginners | Types of Variables

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024
  • Python Tutorial to learn Python programming with examples
    Complete Python Tutorial for Beginners Playlist : • #1 Python Tutorial for...
    Python Tutorial in Hindi : • #1 Python Tutorial | I...
    Github :- github.com/nav...
    Check out our courses:
    Spring Framework in 8 Full Day Course Live: go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Complete Java Developer Course Batch-3: go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Master Java Spring Development : go.telusko.com...
    Coupon: TELUSKO20 (20% Discount)
    Udemy Courses:
    Spring: go.telusko.com...
    Java:- go.telusko.com...
    Java Spring:- go.telusko.com...
    Java For Programmers:- go.telusko.com...
    Python : go.telusko.com...
    Git : go.telusko.com...
    Docker : go.telusko.com...
    For More Queries WhatsApp or Call on : +919008963671
    website : courses.telusk...
    Editing Monitors :
    amzn.to/2RfKWgL
    amzn.to/2Q665JW
    amzn.to/2OUP21a.
    Follow Navin Reddy on Instagram: / navinreddy20
    Subscribe to our other channel:
    Navin Reddy : www.youtube.co....
    Telusko Hindi :
    www.youtube.co....
    Donation:
    PayPal Id : navinreddy20
    Patreon : navinreddy20
    www.telusko.com...

Комментарии • 208

  • @karthick2237
    @karthick2237 5 лет назад +130

    This is exactly called Teaching.
    Give him an award.🏆

    • @crickettrendzz5477
      @crickettrendzz5477 4 года назад +7

      Do you know why he didn't gave you a like 😂
      Because the caption of this channel is *we don't teach we educate*
      😂

    • @tudos9209
      @tudos9209 3 года назад +1

      @@crickettrendzz5477 he is tuting..

  • @AashishKumar-vb3qb
    @AashishKumar-vb3qb 5 лет назад +29

    Animations are very effectively used !!!

  • @kosmic000
    @kosmic000 6 лет назад +27

    world class instructor

  • @mascotacademy2100
    @mascotacademy2100 5 лет назад +19

    You are a great teacher. Keep it up please

  • @chinmaydas4053
    @chinmaydas4053 6 лет назад +3

    Sir now your videos are much better bcz you are teaching programming not programming languages.. which is very rare 🙏🙏🙏..

  • @crickettrendzz5477
    @crickettrendzz5477 4 года назад +8

    Good audio quality
    Good graphics
    Good explanation skills
    😉 These are the things that many videos in the youtube lack
    And hence they are inconvenient
    But welcome to telusko learnings where these are satisfied

    • @KeremAli-cm3pj
      @KeremAli-cm3pj 5 месяцев назад

      bruh
      ive seen many much better edits and graphics and explaining. also ive seen way better audio

  • @rakeshsanthapuri9933
    @rakeshsanthapuri9933 5 лет назад +53

    Give lot of salary to your graphic designer..its amazing😀😀

  • @the_pixelstoryy
    @the_pixelstoryy 4 года назад +15

    civil engineer learning python..:) :).. thanks for making it interesting and simple..

    • @anindian4601
      @anindian4601 3 года назад +1

      @@perfectrahul495 Here mechanical engineer bro.

    • @akashk7507
      @akashk7507 3 года назад +1

      @@anindian4601 same here brother

    • @anindian4601
      @anindian4601 3 года назад +1

      @@akashk7507 😊 nice to hear bro

    • @akashk7507
      @akashk7507 3 года назад

      @@anindian4601 BTW you are from tamilnadu I guess

    • @anindian4601
      @anindian4601 3 года назад +1

      @@akashk7507 No bro

  • @saranya3508
    @saranya3508 6 лет назад +9

    Sir Thanks for the python tutorial series :)I am started learning python from your series You are the best sir.

  • @BoomcoreIsLive
    @BoomcoreIsLive 5 лет назад +7

    I used
    c1.wheels=10
    And it affected only c1.wheels, not c2.wheels and car.wheels...
    After, If we use car.wheels=5, it affects car.wheel and c2.wheels and not c1.wheels
    When i use c2.wheel=30, it affects only c2.wheels,... This means it creates new space when changing values specifying object name like c1.wheels and c2.wheels

    • @rodwynnejones
      @rodwynnejones 5 лет назад +2

      I think I've worked it out. When you do, c1.wheels = 5 you are declaring a new variable for the object (it just happens to have the same name as the class variable) and signing it '5'. If you output it's 'id'...print(id(c1.wheels))... it will be different to c2.wheels and Car.wheels. (c2.wheels and Car.wheels will have the same id)

    • @Mohan-yj3bt
      @Mohan-yj3bt 5 лет назад

      Instead of doing that, try this
      classname.attribute = value
      i think you will get it

    • @mohdibrahim1995
      @mohdibrahim1995 4 года назад

      because it way of declaration if you calling class and storing that in to a variable then if you do any change with that variable then it will effect only that variable class not every variable where the class is calling

  • @Rajadahana
    @Rajadahana 2 года назад +1

    We have two types of variables
    1. Class variables or Static variables - (e.g. wheels) - which are stored in the class namespace
    2. Instance variables - (e.g. com, mil) - which are stored in instance namespace

  • @debjanighosh7875
    @debjanighosh7875 4 года назад +1

    Hi Navin,
    This class and instance variable is very much clear. But can u please explain me the below code and it is working fine also.
    class car():
    wheel = 4
    def __init__(self):
    self.mil=10
    self.name="BMW"
    c1=car()
    c2=car()
    c1.wheel=5
    print(c1.mil,c1.name,c1.wheel)
    print(c2.mil,c2.name,c2.wheel)
    Output:
    10 BMW 5
    10 BMW 4

    • @prameela2709
      @prameela2709 7 месяцев назад +1

      I too got this doubt

  • @omprakashgupta9413
    @omprakashgupta9413 4 года назад +2

    Congrats for being 1M+ Subscribers.... This is the proof of your quality teaching. Keep it up. Thanks a lot...💖💖💖💖

  • @sahilrajput9037
    @sahilrajput9037 4 года назад +4

    the more videos i watch the more amazed i get thank you so much sir

  • @jainsameer1986
    @jainsameer1986 4 года назад +5

    Well Explained Mr. Navin. And as usual :).
    May be worth also, explaining the importance of "modifying class variables with class names only" and contrasting the effect of "modifying class variables with object names".

  • @Unknown804.1
    @Unknown804.1 11 месяцев назад +1

    Here you go 🏆

  • @hellobro495
    @hellobro495 4 года назад +3

    Instance variable can only change the value of wheels for themselves whereas class can change for all of them

  • @adil07869
    @adil07869 4 года назад

    This right side explanation makes it more clear and easy to understand

  • @yashshreeshinde4394
    @yashshreeshinde4394 4 года назад +8

    Your content and way of teaching is really amazing,your the best teacher I have seen till now in terms of programming,A BIG THANK YOU!✨

  • @sharmilasherin4788
    @sharmilasherin4788 2 года назад

    u are the best teacher ever

  • @Kennensiemich
    @Kennensiemich 5 месяцев назад

    Best teacher of Universe 🥇

  • @mdfaaz1611
    @mdfaaz1611 Год назад

    Huge respect, sir even if you make an army, i would be one of the loyal soldiers, because we will never lose a battle with a commander like you. 🌍

  • @Aromal_Dileep
    @Aromal_Dileep 7 месяцев назад +1

    when is change class variable with c1.wheels =5 . It only changes for c1 not for the c2. I thought static variable would change the value for all the objects even if we modify class variable with objects

  • @doruksenocak2117
    @doruksenocak2117 2 года назад

    This is the video I've been looking for a long time, Thanks Sir

  • @shubhamwaingade4144
    @shubhamwaingade4144 11 месяцев назад

    Thank you for short and crystal clear explanation!

  • @AnonymousMan-w1d
    @AnonymousMan-w1d 5 лет назад +2

    wow , navin sir you have got a huge fanbase , no dislikes on this video at all

  • @vasudevareddy5378
    @vasudevareddy5378 5 лет назад +8

    Starting Music is good, loved it

  • @kaarthikh6956
    @kaarthikh6956 2 года назад

    sir
    thank you very much for your effort
    i was very new to these
    since your explanation is very clear, i am able to understand very easily
    i am very happy that you are teaching these for free

  • @madhvishrivastava3646
    @madhvishrivastava3646 9 месяцев назад

    Thank you so much for making this topic so simple and easy.🙏

  • @Ertyuiigff-sq5fi
    @Ertyuiigff-sq5fi 4 года назад

    What a teacher he is it just amazing

  • @sayantanchakraborty75
    @sayantanchakraborty75 4 года назад +1

    hi sir, hope you are doing good and staying fit and healthy. I really love your teaching . I have a question. Here I am accessing the static variable outside the class using class name. But when I am trying to change the value of the static variable outside the class using object name it is changing the value of wheel for both the objects. For eg, c1=Car()
    c2=Car()
    c1.company='Toyota'
    c2.wheels=7
    print(c1.company,c1.mileage,c1.wheels)
    print(c2.company,c2.mileage,c2.wheels)
    This code should give error right ?!! but instead it is changing the value of wheel for the objects. Kindly clear out my confusion. Thank you sir and always stay blessed.

    • @talhatayyab6422
      @talhatayyab6422 4 года назад +2

      Hi Sayantan,
      c2.wheels=7
      will create a new "object variable" for c2 object.
      It does not have anything to do with Car.wheels
      Car.wheels is a separate "class-variable"
      You can create n number of variables for any object. e.g.
      c2.a=5
      c2.b=8
      c2.c=10
      c2.wheels=7
      All will create object variables for c2 with no link to class variable.
      Now, when you print(c2.wheels) It will print the object variable wheels not the Car.wheels
      Hope you Understand!!

  • @iradhakrishna8197
    @iradhakrishna8197 4 года назад

    Graphics in the video makes it very easier to understand

  • @leyanthreddy1436
    @leyanthreddy1436 4 года назад +2

    Really u r a legend ❤️❤️❤️❤️❤️❤️

  • @Arpit_Arora
    @Arpit_Arora 3 года назад

    legendary Sir ji

  • @dihanlin231
    @dihanlin231 2 года назад

    thank you so much omg this is perfect for understanding class/static variables in python!

  • @gagansehra5344
    @gagansehra5344 6 лет назад +1

    thanks sir for teaching us in such a wonderful way

  • @indology7975
    @indology7975 9 месяцев назад

    BEST TEACHER

  • @fktube3039
    @fktube3039 3 года назад

    you are a great teacher thank you keep going

  • @rakeshparmar8943
    @rakeshparmar8943 4 года назад

    Thanks for teaching about types of variable

  • @sachinhabib9440
    @sachinhabib9440 4 года назад

    Superb explanation Sir

  • @Ayesha_Parande
    @Ayesha_Parande 2 года назад +1

    Really good 👍

  • @shashikantchaudhary3542
    @shashikantchaudhary3542 6 лет назад +2

    class Cars:
    wheels = 4
    def __init__(self):
    self.mil = 10
    self.com = "BMW"
    c1=Cars()
    c2=Cars()
    c2.wheels=5
    Cars.wheels=55
    print(c1.wheels)
    print(c2.wheels)
    OUTPUT
    55
    5
    EXPECTED OUTPUT
    55
    55
    Please explain

    • @AlDawoode
      @AlDawoode 5 лет назад +2

      I guess that when you access the wheels variable from the object so you will create new instance varible with the same name "wheels".
      But when you access the wheels variable from the class name so you change the value of the static variable "wheels".
      I just guess :D
      i had the same issue.

  • @alimdeen6921
    @alimdeen6921 3 года назад

    Great constructor you Are sir😍🔥

  • @Alberta_Farmer
    @Alberta_Farmer 2 года назад

    Such a great tutor!

  • @vasubabus
    @vasubabus 5 лет назад

    Simple and perfect explanation

  • @madhavideore4038
    @madhavideore4038 2 года назад

    HEYYYY Navin you are ossum.... thanks for each python video....

  • @publicuser775
    @publicuser775 4 года назад

    This sometimes happens with some cars hahah :D. PS. Your classes are the best !
    Regards!

  • @titojoseph410
    @titojoseph410 4 года назад

    Naveen.....You are awesome....

  • @shreyanshgupta3868
    @shreyanshgupta3868 4 года назад

    Congrats for 1M subscribers

  • @moshahid8257
    @moshahid8257 4 года назад +2

    But c1.wheels=5 is also working.

  • @v.suresh2629
    @v.suresh2629 4 года назад +1

    hello sir
    if u telling the particular topic pls tell us what are the applications abd few examples by using the topic
    and we can undestand quickly about the topic and we can think about it

  • @NitishRaj
    @NitishRaj 3 года назад

    Hi Navin. What do you say ? Python should not let us change class variables data using object. And if so then, it should change for all existing objects, thats how meaningful concept of class variables comes into play. C++ has no instanced variables concept for this reason only. Abstraction should be same for all instances i.e. interface box should be same.

  • @meershahidmanzoor
    @meershahidmanzoor 3 года назад

    i don't know how can i express my love for this man😍😍😘😘😘😘

  • @umasanodiya6917
    @umasanodiya6917 5 лет назад

    Great sir ji 🤘

  • @asmitabarman7404
    @asmitabarman7404 4 года назад +1

    instead of defining compare can we use
    if c1.age==c2.age & c1.name==c2.name
    instead of
    defining in compare with self and other argument?

  • @sindhubasavanna1927
    @sindhubasavanna1927 5 лет назад

    master of python!!!!

  • @balajirami2777
    @balajirami2777 6 лет назад

    I'm done with the series and waiting for the upcoming videos and please post them asap Naveen garu..thank you

  • @dishikaraju7776
    @dishikaraju7776 4 года назад

    Thank you so much for all your vedios, those are very useful. But im expecting theory notes from you. Practical part everything is fine.

  • @KoreaRwkz
    @KoreaRwkz 4 года назад +1

    How does namespace differ from heap memory? How do they fit together in the grander scheme of memory/space?

  • @sonamuhialdeen7866
    @sonamuhialdeen7866 3 года назад

    So good tutorial

  • @anantmittal9981
    @anantmittal9981 3 года назад +1

    Oh WOW...!!

  • @imranshaikh115
    @imranshaikh115 4 года назад

    Great sir Thanks a lot

  • @muddyfingers9582
    @muddyfingers9582 3 года назад +1

    thank you random indian man for letting me survive this years ict class

  • @sanjukriplani502
    @sanjukriplani502 3 года назад

    Thank You sir....❤️

  • @harshasai6660
    @harshasai6660 4 года назад

    but we can change the value of the class variable for an object
    c1.wheels=3
    print(c1.wheels) gives 3
    print(c2.wheels) gives 4

    • @mohdibrahim1995
      @mohdibrahim1995 4 года назад +2

      because it way of declaration if you calling class and storing that in to a variable then if you do any change with that variable then it will effect only that variable class not every variable where the class is calling, so it will be limited to that variable only it will not effect globally

    • @prameela2709
      @prameela2709 7 месяцев назад

      ​@@mohdibrahim1995then what's the difference between instance and class variables?

  • @AdarshYadav-tt5ry
    @AdarshYadav-tt5ry 6 лет назад +7

    Sir, I have a doubt
    at 4:34 in video
    if i write c1.wheels=100, then value of "wheels" only change for c1 not c2, then why we will call it class variable but not instance variable.

    • @usamaakmal3450
      @usamaakmal3450 6 лет назад +1

      yes, I tried that two it only affects only the referred objects property.

    • @Mohan-yj3bt
      @Mohan-yj3bt 5 лет назад +1

      Instead of doing that, try this
      classname.attribute = value
      i think you will get it

    • @mohdibrahim1995
      @mohdibrahim1995 4 года назад +1

      because we are taking class as c1 and we are changing the value of c1 only but if you declare that in class_nameSpace then it will effect both c1 and c2 so if you change like ex: c2.whlees=25 it will show 25 for c2 not for c1 its area of declaration . try this

  • @maheshvangala8472
    @maheshvangala8472 3 года назад

    Even You can change Class variables using object.But It will affect variables of that object

  • @naimurhasanrwd
    @naimurhasanrwd 5 лет назад

    Thank you.

  • @shalinisachdev7384
    @shalinisachdev7384 4 года назад

    Hi Navin , you are the best tutor . However from the OOP video onwards , I am a little lost and I know its because I am unable to relate , you are still superb. I come from a non technical back ground. Is there any other good reading material that you can refer me back to, just to understand the fundamental/basic of the OOP. Tried many other websites but no one is even close to you. So thought of checking with you directly

  • @bareerakhan7569
    @bareerakhan7569 6 лет назад

    Thank you sir you are awesome

  • @ahmedmagdi7873
    @ahmedmagdi7873 6 лет назад +1

    the best video

  • @julie8737
    @julie8737 6 лет назад

    u r my CS god

  • @rakeshparmar8943
    @rakeshparmar8943 4 года назад

    Nice sir

  • @Ghost-Studios-Channel
    @Ghost-Studios-Channel 5 лет назад

    Thank you sir

  • @jaheerkalanthar816
    @jaheerkalanthar816 4 года назад +1

    for i in range(1,100):
    print("First class teacher in world")

  • @SoumyaranjanMohanty-nn6pk
    @SoumyaranjanMohanty-nn6pk 6 лет назад

    Awesome 👍

  • @anindian4601
    @anindian4601 3 года назад

    Class/Static Variables = GLOBAL VARIABLES
    Instance Variables = LOCAL VARIABLES.

  • @mannan310160
    @mannan310160 4 года назад +2

    Assign a new value to class variable like c1.wheels = 6, it behalves like instant variable, Please explain.

    • @praveen1193
      @praveen1193 4 года назад +2

      print(c1.wheels)
      first it will check in c1 object , if not found it will check class level variable.
      for print(c1.wheels) it worked fine, because there is no wheels variable in c1 object.
      But when you write c1.wheels=6 it won't change the value of static variable, it simply creates a new variable in your c1 object. that's why you are getting different value.
      c1.wheels=6 creates a new variable in c1 object with name wheels , So when you access you will get 6 rather than your static value.

  • @papachoudhary5482
    @papachoudhary5482 6 лет назад

    Thanks

  • @yashsaxena9313
    @yashsaxena9313 4 года назад +2

    Hello Sir your explanation about each topic is so good, but I have a problem regarding class variable. I'm not defining any class variable inside a class but whenever I access it like
    car.wheels = 3
    print(car.wheels)
    it's printing it..and I don't know why and how..

    • @shivaprasadmallikarjunaiah3751
      @shivaprasadmallikarjunaiah3751 Год назад

      Interesting find. ...yes, I tried that and saw the same behaviour. Must be an advanced topic for another day😀

  • @sahilasopa
    @sahilasopa 4 года назад

    while x == 1
    print('you are best')

    • @mohdibrahim1995
      @mohdibrahim1995 4 года назад

      x value need or else it will give you an error

  • @suniladitya1016
    @suniladitya1016 4 года назад +1

    And if we change the value for a instance variable using class name then the value for all the object variables changes

  • @HKNAGPAL7
    @HKNAGPAL7 5 лет назад

    2:40 the main difference

  • @avihk4152
    @avihk4152 4 года назад

    so simple!!

  • @Tab_07_
    @Tab_07_ 3 года назад

    Sir please tell us how did you edit your videos with such animation
    Please sir
    If possible then try to make a separate video on it. Its a humble request for your subscribers

  • @anasraza9709
    @anasraza9709 5 лет назад

    i have a qs related to variables access specifier
    should we use public instance variables or private ones then use getters and setters?
    which approach is good in python?

  • @vamsichittem2296
    @vamsichittem2296 4 года назад +1

    What is local variable ??

  • @LaymanLearnings
    @LaymanLearnings 5 лет назад +2

    c1.wheels also working without affecting c2. so how wheels is different from instance(milage).

    • @BaapBaapBetaBeta
      @BaapBaapBetaBeta 4 года назад

      When you change either of c1.wheels or c2.wheels, both the object will get effected. That does not happen in the case of c1.mileage.

    • @kaushalJainer
      @kaushalJainer 4 года назад

      @@BaapBaapBetaBeta no bro when i use c1.wheel =3 but my class.wheel=4 and i print(c1.wheel) then the output is 3 not 4 ,it means that c1 is also able to change the variable but c2 remains unaffected

    • @nageshg3832
      @nageshg3832 4 года назад

      ​ Kaushal Jainer Techie Even i tried that ,then wheels might not be class variable, In java variable which is declared inside the class and outside method is instance variable and variable which is declared inside the method is local variable may be the same applies here too.

  • @mascotacademy2100
    @mascotacademy2100 5 лет назад

    Do you people have paid/ advanced tutorials on Django or other python languages?

  • @omshanpatel1258
    @omshanpatel1258 2 года назад

    sir when we create a static variable and manipulate it by using object then what will happen internally? and shall it affects the another object of the same class?

    • @ajaymishra8162
      @ajaymishra8162 Год назад

      it will not affect other objects of the same class. if you try to change the static var using instance then it will only create a new instance of that variable for the object. This will not affect the entire class.

  • @mr.haristotle
    @mr.haristotle 4 года назад +1

    At 4:26 , what if i put c1.wheels = 5 instead of car.wheels=5...????

  • @kuruvamalappa2853
    @kuruvamalappa2853 6 лет назад

    Good sir

  • @shadow-gr7ls
    @shadow-gr7ls 4 года назад +1

    is there any software that can show output in the form of boxes like 1:08 in the video tutorial!
    This question needs a reply
    please reply

  • @woahelmo_
    @woahelmo_ 3 года назад

    i fckn love you, thats the teaching

  • @rohit_ec4498
    @rohit_ec4498 3 года назад +1

    ye hamare sir h, ye unki car h ,aur ye hamari padhai ho rahi h

  • @hemachandiran3984
    @hemachandiran3984 3 года назад

    But actually there are three types of variables
    1. Instance variable
    2. Static(class variable)
    3.Local variable

  • @hajarabdullah4648
    @hajarabdullah4648 4 года назад

    Mr.Navin how can i make a real projects with python , can you provide me websites that i can improve my skills

  • @sonud8202
    @sonud8202 4 года назад

    can we change the value of class variable for a particular object?

  • @omshanpatel1258
    @omshanpatel1258 2 года назад

    sir when we create a static variable and manipulate it by using object then what will happen internally? and shall it affects the another object of the same class? can you please explain that in some more details?

    • @shivaprasadmallikarjunaiah3751
      @shivaprasadmallikarjunaiah3751 Год назад

      I wish he explained that aspect, like many others also noted. What I found out is that if you manipulate(change) a static variable(say, wheels = 4) by using object(say, car1.wheels = 5), that is entirely valid, but the value is effective only to the object(car1). It does not afect other objects. If you create an object (car2) later, then print(car2.wheels) will print 4 (the value defined by the static variable) not 5. That is why it is also termed "static variable" because it is static.

  • @shubhamraja1345
    @shubhamraja1345 6 лет назад +1

    C1.wheels = 5(suppose)
    It will make change only for c1 object.
    If cars.wheels =5 will change for all object of that class...so how we can say that "wheels" is a "static" variable...and pls tell us what's happening behind the scenes ?

    • @hariwarshan931
      @hariwarshan931 6 лет назад

      In class variable we can change the variable with both cases either by object name or by class name..if we change by class name it will change the entire wheels...if we change by object name it will change onu for that object wheel...and you cannot change mileage by class name as it is an instance variable...

    • @RanjithKumar-qj9mn
      @RanjithKumar-qj9mn 5 лет назад

      Static is class variable right so it should not change by object value assignment