BankAccount ฝากเงิน

📋 โจทย์

คลาส BankAccount(__init__ balance) มี deposit(amount) และ get_balance() — รับ balance เริ่มต้น แล้วจำนวนเงินฝาก แสดงยอดใหม่

⚠️ ข้อจำกัด

จำนวนเป็น int ≥ 0

📝 ตัวอย่าง

ตัวอย่างที่ 1
Input:
100
50
Output:
150
🔓 ดูเฉลย
class BankAccount:
    def __init__(self, balance):
        self.balance = balance
    def deposit(self, amount):
        self.balance += amount
    def get_balance(self):
        return self.balance
b=BankAccount(int(input()))
b.deposit(int(input()))
print(b.get_balance())
🐍 main.py

กด Run เพื่อรันโค้ด หรือ ตรวจคำตอบ เพื่อตรวจ test cases