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 #---------------------------------------------------------------------
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
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!! 🙏
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
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?
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
#---------------------------------------------------------------------
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
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!
Literally teaching me more/better than my textbooks :) Thank you so much for these videos!!!
Object oriented programming was so hard for me until I watched these tutorials. I might just start learning Java! Thanks Bro.
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
Classes and their uses are very well explained. Thank you very much.
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!! 🙏
Thanks for the content.
Best Java teacher on UA-cam hands down
this video was great, as always! Tnx Bro
This is insanely well explained and so simple. Just incredible!!!
Beautiful thanks for the explanation
Bro You are the Best UA-camr Love U from Pakistan😍🤩😘
your video are nice!!
Thank you!
Thanks for the video, bro
Thanks bro
Thanks Super Hero, Bro Code
Thank You.
love the format these vids bro ,, "Organic Chem tutor of python"
This man is saving my life fr❤
osm
thank you
best tutor ever since thanks :))
ctrl + forward slash after highlighting the code makes the highlighted code comments and vice versa....hope that helps ease work
simply awesome
Great stuff pls keep uploading!
Great videos!
Got a question - can instance variables be updated after creating the instance?
can we do: car_1.make = "Chevy" ?
Amazing tutorial !!
Perfect 🥰🥰
Good lesson
Thx
Awesome
Thank you bro
Wow!
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
i liked and subscribed lol 4 minute video is way more clear than the other 10-15 minute videos on here..
boom bam
thx 4 vid bro !
love u
nice
What if I have another class that needs the Wheels variable. How do I pass that to another class?
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?
Gangster
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.
It might just be print(wheels + car) just adding the wheels amount to the amount of cars you inputed.
🛋😌🤓
thanks man!
no one did this comment so i had to do it 🙃
prayer+=1😂
comment
Comment comment etcetera
i did again bruhhhhhhhhhhhhhhhhhhhhhh
bla bla
comment