Ms. Class Python I

catundanatalia

Natália Catunda

Posted on July 5, 2020

Ms. Class Python I

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)
Enter fullscreen mode Exit fullscreen mode
  1. You create the class variable kind to share the attribute.
  2. We use the init to initialize the instance.
  3. name its an attribute of an object.
  4. And all immutable objects: one, two, and three.

Thanks for reading! ;))

💖 💪 🙅 🚩
catundanatalia
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.

Related

Ms. Class Python I
beginners Ms. Class Python I

July 5, 2020