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 പേരുകൾ capital letter-ൽ തുടങ്ങുന്നു: Student, BankAccount.

Challenge

+35 XP

__init__ title-ഉം price-ഉം സൂക്ഷിക്കുന്ന class Book എഴുതൂ. Book("Python Basics", 350) ഉണ്ടാക്കി അതിന്റെ title-ഉം price-ഉം ഒരു വരിയിൽ print ചെയ്യൂ.

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