python code 9

Please make sure the code is your own work and the memo as well. Please use the formula that in the assignment sheet not in the question. If you have any question let me know.