Ms. Class Python I
Natália Catunda
Posted on July 5, 2020
Most people have difficulties to understand classes,
little warriors you're not alone. In this post, I'll try to teach you, how to understand class and apply it in your life!
class Drinks:
kind = "Drink"
def __init__(self,name):
self.name=name
one = Drinks("Orange juice")
two = Drinks("coca-cola")
three = Drinks("water")
print(two.kind)
print(two.name)
- You create the class variable kind to share the attribute.
- We use the init to initialize the instance.
- name its an attribute of an object.
- And all immutable objects: one, two, and three.
Thanks for reading! ;))
💖 💪 🙅 🚩
Natália Catunda
Posted on July 5, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.