Apr-04-2019, 08:30 PM
Ok.
type
is like cat
on Windows, it just shows the contents of the file.E:\Projects\etc>type spam.py def f(balance,r,A,n): r=5.0 A=1000.0 n=18 balance=10000 L=[] for year in range(n): balance=(balance)*(r/100.0 +1)- A L.append(balance) if balance <=0: balance=0 break return L print(f(balance,r,A,n)) print(L,n) #should print the last non negative value and the iterations #needed to get there E:\Projects\etc>python spam.py Traceback (most recent call last): File "spam.py", line 16, in <module> print(f(balance,r,A,n)) NameError: name 'balance' is not defined