Skip to content

Commit 8ffbcf3

Browse files
committed
updating exercise2
1 parent a89b858 commit 8ffbcf3

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Perp-Exercise/exercise2.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# adding type annotation
22

3-
def open_account(balances: dict[str,int], name:str, amount: float) -> None:
3+
def open_account(balances: dict[str,int], name:str, amount: int) -> None:
44
balances[name] = amount
55

66
def sum_balances(accounts: dict[str,int]) ->int:
@@ -10,7 +10,7 @@ def sum_balances(accounts: dict[str,int]) ->int:
1010
total += pence
1111
return total
1212

13-
def format_pence_as_string(total_pence: int) -> float:
13+
def format_pence_as_string(total_pence: int) -> str:
1414
if total_pence < 100:
1515
return f"{total_pence}p"
1616
pounds = int(total_pence / 100)
@@ -23,10 +23,11 @@ def format_pence_as_string(total_pence: int) -> float:
2323
"Georg": 831,
2424
}
2525

26-
open_account("Tobi", 9.13)
27-
open_account("Olya", "£7.13")
26+
#changing float to int (9.13 to 913)
27+
open_account(balances,"Tobi", 913)
28+
open_account(balances,"Olya", 713)
2829

2930
total_pence = sum_balances(balances)
30-
total_string = format_pence_as_str(total_pence)
31+
total_string = format_pence_as_string(total_pence) #correct the function name
3132

3233
print(f"The bank accounts total {total_string}")

0 commit comments

Comments
 (0)