+ 3

Python for Finance Code Repo 10.2

When I select run, it does not show me if I did the code correctly, the screen just flashes. This is what I did: (ps. on pc, I did not see an option to add my code elsewhere, like on my tablet) import numpy as np import numpy_financial as npf #price for 2018-2021 bitcoin = [3869.47, 7188.46, 22203.31, 29391.78] an_array = np.array(bitcoin) multiplied_array = an_array * 10 print(multiplied_array) mining_array = [-500000, 38694.7, 71884.6, 222033.1, 293917.8] npf.irr(mining_array)

4th Mar 2022, 7:37 AM
Stacey Prahl
Stacey Prahl - avatar
9 odpowiedzi
+ 5
Stacey Prahl , Rik Wittkopp , Stacey, did you get an error message by running the code??? i have taken a look at the code of 10.2, but could not find an issue. the final print statement is not done there, may be this causes an error. but i found a typo in the code of 11.2 code (plotting): bitcoin_newValue = np.mulitply(bitcoin, bitcoin_owned), but has to be ...multiply(...) please correct this, it should work properly...
5th Mar 2022, 11:39 AM
Lothar
Lothar - avatar
+ 3
Lothar Since you have pro & have completed the Python for Finance course, could you help Stacey Prahl with this problem.
5th Mar 2022, 9:24 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Stacey Prahl I get a result for the existing print line, and another result when I print the last line. import numpy as np import numpy_financial as npf #price for 2018-2021 bitcoin = [3869.47, 7188.46, 22203.31, 29391.78] an_array = np.array(bitcoin) multiplied_array = an_array * 10 print(multiplied_array) mining_array = [-500000, 38694.7, 71884.6, 222033.1, 293917.8] print(npf.irr(mining_array))
4th Mar 2022, 8:29 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
I took out the additional code from 11.2, and ran it again. This is what I got for a result: [38694.7 71884.6 222033.1 293917.18]
5th Mar 2022, 6:49 AM
Stacey Prahl
Stacey Prahl - avatar
0
My code Repo symbol omly shows 1/2 a diamond, which seems to me that I'm only half right.
5th Mar 2022, 6:51 AM
Stacey Prahl
Stacey Prahl - avatar
5th Mar 2022, 6:57 AM
Stacey Prahl
Stacey Prahl - avatar
0
I had forgotten to add print before npf.irr(mining_array) to be print(npf.irr(mining_array)) but I still did not get the same answer as the expected result.
5th Mar 2022, 6:59 AM
Stacey Prahl
Stacey Prahl - avatar
0
I did not get the expected result" 0.0729721591 after adding the print() before the npf...))
5th Mar 2022, 7:03 AM
Stacey Prahl
Stacey Prahl - avatar
0
it looks like your initial investment price is wrong, you have 50k instead of 500k and remove the first print statement the rest of the code looks fine.
15th May 2022, 5:08 PM
James
James - avatar