DEV Community

loading...
Cover image for Ms. Class Python I

Ms. Class Python I

Natália Catunda
・1 min read

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! ;))

Discussion (6)

Collapse
target899 profile image
Dave

I love your article because it has given me some insight into Python. Please, recently I got admission at WorldQuant University (WQU) Scientific Computing and Python for Data Science Unit. I have no basis or foundations in Python. The first phase of the course is expected to last for 8 weeks. After reading your article, I realized I have to have a strong foundation in Python, but I do not have. Please, any advice would be much appreciated. Thank You.

Collapse
nataliacatundafr profile image
Natália Catunda Author • Edited

@dave its makes me very happy, i'm grateful for this comment .

Collapse
target899 profile image
Dave

My pleasure Ma'am. Ma'am, please, can you recommend any material on Python for a beginners

Thread Thread
nataliacatundafr profile image
Natália Catunda Author
Thread Thread
target899 profile image
Dave

Thank You, Ma'am

Thread Thread
target899 profile image
Dave

Ma'am, please, the course on Udacity is not free. I listened to the introductory video from Juno. Her explanation of the course made me fall more in love with Python. Honestly speaking I would have loved to join the course, but I do not have money to do so. Since the lockdown was initiated in my country, I lost my job as a teacher and till now, I still do not have a job.
All the same, thank you, Ma'am, for your efforts.