Lesson 31 of 34

Classes & Objects: మీ సొంత Data Types

10 min 35 XP

class అంటే ఒక బ్లూప్రింట్. దాని నుండి తయారయ్యే ప్రతిదీ object. ఉదాహరణ: Student class; Arun, Priya objects.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

object సృష్టించగానే __init__ ఆటోమేటిక్‌గా నడుస్తుంది. self అంటే “ఈ object”. self.name = name పేరును object లోపల నిల్వ చేస్తుంది.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

సంప్రదాయం ప్రకారం class పేర్లు పెద్ద అక్షరంతో మొదలవుతాయి: Student, BankAccount.

Challenge

+35 XP

title, price ను నిల్వ చేసే __init__ ఉన్న Book class రాయండి. Book("Python Basics", 350) సృష్టించి దాని title, price ను ఒకే లైన్‌లో print చేయండి.

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.