Can a class variable be any type?


Can a class variable be any data type?


Yes, a class variable can be any defined data type including instances of other classes.


Referring to this exercise:

What’s the point of creating classes? Couldn’t we have just as easily mentioned minimum_passing as a standalone global variable?

I think the answer is that this exercise was just a simple example, but i’ve been learning about classes since the past 3-4 months now & still don’t see any use of defining classes irl.


The purpose of classes is to have a template of how the objects are designed. Without any designs, you cannot have an object. Minimum_passing is used for the purposes of the exercise and is not needed to be in a global spectrum.


I strongly recommend watching the short video about Classes and Objects in Python linked to below. I think he does an excellent job at explaining the topic in a way that beginning coders can understand and grasp:


So basically defining and using a class will simplify things for you in the future? From what I understand, an object created from a class can contain functions, lists, dictionaries, loops… (etc.) that can be used over and over again throughout the program. Am I correct in this understanding? Thank you!

Basically with classes, you can create any type of data type that you want. Let’s say a customer class, containing customers’ username, location, billing plan, etc. You define it once at the top, and then use it throughout the whole production cycle of your business. Also, we can create more complex versions of data structures such as list, dictionary, set, etc. A great example of this is the legendary linked list whose implementation is an essential problem for programmers.

1 Like

This video is amazing. Unlike the content we are learning and (paying) for it explains with examples and analogies.