# class variables = Shared among all instances of a class # Defined outside the constructor # Allow you to share data among all objects created from that class class Student: class_year = 2025 num_students = 0 def __init__(self, name, age): self.name = name self.age = age Student.num_students += 1 student1 = Student("Spongebob", 30) student2 = Student("Patrick", 35) student3 = Student("Squidward", 55) student4 = Student("Sandy", 27) print(f"My graduating class of {Student.class_year} has {Student.num_students} students") print(student1.name) print(student2.name) print(student3.name) print(student4.name)
# class variables = Shared among all instances of a class
# Defined outside the constructor
# Allow you to share data among all objects created from that class
class Student:
class_year = 2025
num_students = 0
def __init__(self, name, age):
self.name = name
self.age = age
Student.num_students += 1
student1 = Student("Spongebob", 30)
student2 = Student("Patrick", 35)
student3 = Student("Squidward", 55)
student4 = Student("Sandy", 27)
print(f"My graduating class of {Student.class_year} has {Student.num_students} students")
print(student1.name)
print(student2.name)
print(student3.name)
print(student4.name)
what is the use of class variables, like can you give me basic for-dummies example?
How did you know I was struggling with this? Your timing is intuitive and impeccable
Please continue making this series. It is tremendously valuable. Cannot thank you enough Bro
Make a video about Django and python
welcome back brotha, hope you been well, thanks for all that you do
BRO what happened?? 76 videos in 2 days???
Even though I know classes reasonably well i always find nuggets in your videos. 🎉
Thank You
You are the best one to teach Python.
THE GOAT IS BACK 🔥 love u
Thanks!
You are very good. Love from SINGAPORE!
Please make a tutorial on Nmap in python
reply = input("Reply: ").lower()
while(reply != "yes"):
print("Please Bro!")
reply = input("Reply: ").lower()
print("Thanks Bro!");
Thank you bro❤
Thanks bro
Thanks Bro , would you like to start assembly language please , I find it hard. we understand you're explanation the most .
fun fact - sponge bob was born in 1986- as states his driving license - so he is 38 now
Bro please make django tutorial. It is a Humble request from your loyal follower
___hello___
\__hello\__
:yt: