Python class variables 🚗

Поділитися
Вставка
  • Опубліковано 23 жов 2024

КОМЕНТАРІ • 56

  • @BroCodez
    @BroCodez  3 роки тому +22

    Don't forget to SMASH that LIKE button and
    DROP a random COMMENT down below for the YT algorithm
    🙏
    also here's the code from the video...
    #---------------------------------------------------------------------
    from car import Car
    car_1 = Car("Chevy","Corvette",2021,"blue")
    car_2 = Car("Ford","Mustang",2022,"red")
    #Car.wheels = 2
    print(car_1.wheels)
    print(car_2.wheels)
    #---------------------------------------------------------------------
    class Car:
    wheels = 4 #class variable
    def __init__(self,make,model,year,color):
    self.make = make #instance variable
    self.model = model #instance variable
    self.year = year #instance variable
    self.color = color #instance variable
    #---------------------------------------------------------------------

  • @matheushemerly2244
    @matheushemerly2244 Рік тому +4

    That must be the most informative video I've seen in my life, I didn't even finish my cigarette but it did feel like I just went through a whole book cover to cover

  • @fabian1551
    @fabian1551 Рік тому +7

    Thanks Bro, your videos are short but so helpful if you want to learn something! Surely, one of the best programming channels on UA-cam!

  • @SyedNaqvi-u7r
    @SyedNaqvi-u7r 2 місяці тому

    Literally teaching me more/better than my textbooks :) Thank you so much for these videos!!!

  • @hiiexisthiiexist1284
    @hiiexisthiiexist1284 Рік тому +2

    Object oriented programming was so hard for me until I watched these tutorials. I might just start learning Java! Thanks Bro.

  • @Madani_art
    @Madani_art 9 місяців тому

    2 years ago i watched these python videos , i haven't worked with python in a while so here I'm watching these helpful and straightforward content

  • @anurasenarathna1703
    @anurasenarathna1703 2 роки тому +2

    Classes and their uses are very well explained. Thank you very much.

  • @danilodelucio
    @danilodelucio Рік тому +2

    Man, this video was so helpful! Less than 2 minutes you explained exactly what I want, and I spent few hours searching in Google trying to understand this.
    Thanks a lot!! 🙏

  • @cristiucvladimir7909
    @cristiucvladimir7909 5 місяців тому

    Thanks for the content.

  • @jalillateef5252
    @jalillateef5252 2 роки тому +3

    Best Java teacher on UA-cam hands down

  • @tara2337
    @tara2337 6 місяців тому

    this video was great, as always! Tnx Bro

  • @simonaugustocarroz4447
    @simonaugustocarroz4447 3 роки тому +3

    This is insanely well explained and so simple. Just incredible!!!

  • @purpetualbeats
    @purpetualbeats 3 роки тому

    Beautiful thanks for the explanation

  • @hashimaleemkaka
    @hashimaleemkaka Рік тому

    Bro You are the Best UA-camr Love U from Pakistan😍🤩😘

  • @bedwarschill
    @bedwarschill Рік тому

    your video are nice!!

  • @starwyvern010
    @starwyvern010 4 місяці тому

    Thank you!

  • @lw9954
    @lw9954 2 роки тому

    Thanks for the video, bro

  • @Trapezius_God
    @Trapezius_God 4 місяці тому

    Thanks bro

  • @SelfEngine101
    @SelfEngine101 Рік тому

    Thanks Super Hero, Bro Code

  • @ahiamatagabriel5696
    @ahiamatagabriel5696 2 роки тому

    Thank You.

  • @imanhosseini6908
    @imanhosseini6908 Рік тому

    love the format these vids bro ,, "Organic Chem tutor of python"

  • @reemaj2482
    @reemaj2482 11 місяців тому

    This man is saving my life fr❤

  • @somebody3014
    @somebody3014 2 роки тому

    osm

  • @techlace1195
    @techlace1195 2 роки тому

    thank you

  • @brunohuynh1092
    @brunohuynh1092 2 роки тому

    best tutor ever since thanks :))

  • @abdulhakimlukwago88
    @abdulhakimlukwago88 Рік тому

    ctrl + forward slash after highlighting the code makes the highlighted code comments and vice versa....hope that helps ease work

  • @m.ssulaim8787
    @m.ssulaim8787 3 роки тому

    simply awesome

  • @DoodleAnnaRocks
    @DoodleAnnaRocks 3 роки тому

    Great stuff pls keep uploading!

  • @davidhirschhorn2960
    @davidhirschhorn2960 8 місяців тому

    Great videos!
    Got a question - can instance variables be updated after creating the instance?
    can we do: car_1.make = "Chevy" ?

  • @piotrkopcewicz5227
    @piotrkopcewicz5227 2 роки тому

    Amazing tutorial !!

  • @soroshroshantab5590
    @soroshroshantab5590 2 роки тому

    Perfect 🥰🥰

  • @ahmetaydn4416
    @ahmetaydn4416 2 роки тому

    Good lesson

  • @johnfrancis9668
    @johnfrancis9668 7 місяців тому

    Thx

  • @kemann3815
    @kemann3815 2 роки тому

    Awesome

  • @xplatform2642
    @xplatform2642 3 роки тому

    Thank you bro

  • @beingzero7541
    @beingzero7541 2 роки тому

    Wow!

  • @minimalistEXTREM
    @minimalistEXTREM 2 роки тому

    Cheers Bro, nice Course!
    I got a question here:
    When I define a class with a class variable and then create multiple instances -> then when I change the class variable, all instances get updated; -> then when I change that predifined class variable of a single instance, it doesn't react to any more direct class variable changes, like that:
    class class1:
    classvariable = 0
    instance1 = class1()
    instance2 = class1()
    print(instance1.classvariable,instance2.classvariable) # prints 0, 0
    class1.classvariable = 1
    print(instance1.classvariable,instance2.classvariable) # prints 1, 1
    instance1.classvariable = 0
    class1.classvariable = 2
    print(instance1.classvariable,instance2.classvariable) # prints 0, 2
    Can we determine, from where on the instance's classvariable is separated from the others? Generally, whats the use for that? Looks dangerous...
    Thanks cheers again

  • @joecookieee
    @joecookieee 2 роки тому

    i liked and subscribed lol 4 minute video is way more clear than the other 10-15 minute videos on here..

  • @guntasrinivasulu9642
    @guntasrinivasulu9642 Рік тому

    boom bam

  • @bekturasanbekov1979
    @bekturasanbekov1979 Рік тому

    thx 4 vid bro !

  • @HussainAli-sb1dv
    @HussainAli-sb1dv Рік тому

    love u

  • @uuhju7004
    @uuhju7004 3 роки тому

    nice

  • @lovermonkey
    @lovermonkey 2 роки тому

    What if I have another class that needs the Wheels variable. How do I pass that to another class?

  • @tokih9194
    @tokih9194 2 роки тому

    Lets say,
    class Car:
    def __init__(self,doors):
    self.doors = doors
    def openDoors(self):
    doors = self.doors
    open = True
    def closeDoors(self):
    *open = self.open*?
    How would I access the variable "open" from the method "openDoors" into "closeDoors" method?

  • @micahyasharahla9049
    @micahyasharahla9049 8 днів тому

    Gangster

  • @darrelmasterson5850
    @darrelmasterson5850 3 роки тому

    To use your example, I want Cars.wheels to say the total number of wheels on all defined cars, so, 8 in the case that they each have 4.

    • @andyrockism
      @andyrockism Рік тому +1

      It might just be print(wheels + car) just adding the wheels amount to the amount of cars you inputed.

  • @MissKrake
    @MissKrake Рік тому

    🛋😌🤓

  • @airlanggak5391
    @airlanggak5391 3 роки тому

    thanks man!

  • @ibrahimalbarwani4181
    @ibrahimalbarwani4181 2 роки тому

    no one did this comment so i had to do it 🙃
    prayer+=1😂

  • @arpanshah355
    @arpanshah355 11 місяців тому

    comment

  • @benl3115
    @benl3115 5 місяців тому

    Comment comment etcetera

  • @DesiredFactsDaily
    @DesiredFactsDaily Рік тому

    i did again bruhhhhhhhhhhhhhhhhhhhhhh

  • @dfg2304
    @dfg2304 2 роки тому

    bla bla

  • @jhassee
    @jhassee Рік тому

    comment