Lesson 32 of 34

Methods: Object செய்யும் செயல்கள்

10 min 35 XP

class-க்குள் எழுதும் functions-ஐ methods என்பார்கள். முதல் parameter எப்போதும் self. ஒரு method object-ன் தகவல்களைப் படிக்கவும் மாற்றவும் முடியும்.

Example: edit me and press Run

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

__str__ method இருந்தால், print(object) அழகான உரையைக் காட்டும்.

Example: edit me and press Run

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

Challenge

+35 XP

BankAccount class எழுதுங்கள்: • __init__: balance = 0 உடன் தொடங்கும் • deposit(amount): balance-ல் சேர்க்கும் • withdraw(amount): balance போதுமானால் கழிக்கும், இல்லையென்றால் "Insufficient balance" என print செய்யும் • get_balance(): balance-ஐ return செய்யும்

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