You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defopen_account(balances: Dict[str,int], name:str, amount:int): #dic type str and int
3
+
defopen_account(balances: Dict[str,int], name:str, amount:int)->None: #dic type str and int--- returns none/figured after running --strict flag with mypy
4
4
#Adding a new account
5
5
balances[name] =amount
6
6
@@ -15,10 +15,8 @@ def format_pence_as_string(total_pence: int)-> str: #type int returns type str
15
15
#formatting pence as a string
16
16
iftotal_pence<100:
17
17
returnf"{total_pence}p"
18
-
pounds=int(total_pence/100)
19
-
reveal_type(pounds)
18
+
pounds=(total_pence//100) #floordivision always returns an int
20
19
pence=total_pence%100
21
-
reveal_type(pence)
22
20
returnf"£{pounds}.{pence:02d}"
23
21
24
22
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
27
25
"Georg": 831,
28
26
}
29
27
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)
32
30
33
31
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
0 commit comments