Skip to content

Commit 7dbbd28

Browse files
committed
Fixed all bug, also ran mypy with --strict flag to pick every issue. All bugs have been resolved.
1 parent d937285 commit 7dbbd28

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

Sprint5/type.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
from typing import Dict
3-
def open_account(balances: Dict[str,int], name:str, amount:int): #dic type str and int
3+
def open_account(balances: Dict[str,int], name:str, amount:int)->None: #dic type str and int--- returns none/figured after running --strict flag with mypy
44
#Adding a new account
55
balances[name] = amount
66

@@ -15,10 +15,8 @@ def format_pence_as_string(total_pence: int)-> str: #type int returns type str
1515
#formatting pence as a string
1616
if total_pence < 100:
1717
return f"{total_pence}p"
18-
pounds =int(total_pence / 100)
19-
reveal_type(pounds)
18+
pounds =(total_pence // 100) #floordivision always returns an int
2019
pence = total_pence % 100
21-
reveal_type(pence)
2220
return f"£{pounds}.{pence:02d}"
2321

2422
balances:Dict[str,int] = { #dic type {str:int}
@@ -27,11 +25,10 @@ def format_pence_as_string(total_pence: int)-> str: #type int returns type str
2725
"Georg": 831,
2826
}
2927

30-
open_account("Tobi", 9.13) # balances not passed, amount should be an int and not a float/ string
31-
open_account("Olya", "£7.13")
28+
open_account(balances,"Tobi", 913) # correct passing of the argumenst to functions with balances.
29+
open_account(balances,"Olya", 713)
3230

3331
total_pence = sum_balances(balances) #returntype int
34-
reveal_type(total_pence)
35-
total_string = format_pence_as_str(total_pence) #returntype str and wrong function name
36-
reveal_type(total_string)
32+
total_string = format_pence_as_string(total_pence) #returntype str and wrong function name
33+
3734
print(f"The bank accounts total {total_string}")

0 commit comments

Comments
 (0)