0% found this document useful (0 votes)
57 views2 pages

Code Pal Result

Make research to improve this result.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views2 pages

Code Pal Result

Make research to improve this result.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

class PaypalMoneyAdder:

"""
Class to simulate a Paypal Money Adder.

Attributes:
- balance: float
The current balance in the Paypal account.
"""

def __init__(self, initial_balance: float = 0.0):


"""
Constructor to instantiate the PaypalMoneyAdder class.

Parameters:
- initial_balance: float (optional)
The initial balance in the Paypal account. Default is 0.0.
"""

self.balance = initial_balance

def add_money(self, amount: float):


"""
Adds the specified amount of money to the Paypal account balance.

Parameters:
- amount: float
The amount of money to be added to the balance.

Raises:
- ValueError:
Raises an error if the amount is negative.
"""

if amount < 0:
raise ValueError("Amount cannot be negative.")

self.balance += amount

def get_balance(self):
"""
Returns the current balance in the Paypal account.

Returns:
- float:
The current balance in the Paypal account.
"""

return self.balance

# Example usage of the PaypalMoneyAdder class:

# Creating an instance of PaypalMoneyAdder with initial balance of $100.0


paypal_account = PaypalMoneyAdder(100.0)

# Adding $50.0 to the account balance


paypal_account.add_money(50.0)

# Getting the current balance


balance = paypal_account.get_balance()
print(f"The current balance in the Paypal account is ${balance}.")

You might also like