DEV Community

Cover image for Ms. Class Python I
Nati Thinks Tech
Nati Thinks Tech

Posted on

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

Top comments (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
 
nati_thinks_tech profile image
Nati Thinks Tech • 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
 
nati_thinks_tech profile image
Nati Thinks Tech
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.