In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of January 18th
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #12 exercise sheet]


In this problem you should submit a class as described. Inside the class do not print anything that was not asked!

[IP104] Ambitious Pepe

Now that IP students have learned the basics of programming, they can become filthy rich 😁 At least if they code the bank application!

The Problem

Create a BankAccount class that has the following attributes: account_holder (string) and balance (number).

You should start by creating the __init__ initializer to be able to create a new account with the account_holder name and an optional initial balance, balance.
By default, the balance should be initialized to 0.0.

Then, add some methods to the BankAccount class that allow you to perform certain operations on any bank account:

Constraints

The following constraints are guaranteed in all the test cases that will be given to your program:

Example Input 1 Example Output 1
account_1 = BankAccount("Joy", 3000)
print(account_1.account_holder)
print(account_1.balance)
account_2 = BankAccount("James")
print(account_2.account_holder)
print(account_2.balance)
Joy
3000
James
0.0
Example Input 2 Example Output 2
account_1 = BankAccount("Joy", 3000)
print(account_1.check_balance())
3000
Example Input 3 Example Output 3
account_1 = BankAccount("Joy", 3000)
print(account_1.check_balance())
account_1.deposit(5000)
print(account_1.check_balance())
3000
8000
Example Input 4 Example Output 4
account_1 = BankAccount("Joy", 3000)
print(account_1.check_balance())
account_1.withdraw(2000)
print(account_1.check_balance())
3000
1000
Example Input 5 Example Output 5
account_1 = BankAccount("Joy", 3000)
print(account_1.check_balance())
account_1.withdraw(5000)
print(account_1.check_balance())
3000
Invalid Operation: insufficient funds.
3000
Example Input 6 Example Output 6
account_1 = BankAccount("Joy", 3000)
account_2 = BankAccount("James")
print(account_1.check_balance())
print(account_2.check_balance())
account_1.transfer(account_2, 600)
print(account_1.check_balance())
print(account_2.check_balance())
3000
0.0
2400
600.0
Example Input 7 Example Output 7
account_1 = BankAccount("Joy", 3000)
account_2 = BankAccount("James")
print(account_1.check_balance())
print(account_2.check_balance())
account_1.transfer(account_2, 5000)
print(account_1.check_balance())
print(account_2.check_balance())
3000
0.0
Invalid Operation: insufficient funds.
3000
0.0

Introduction to Programming (CC1024)
DCC/FCUP - University of Porto