CS计算机代考程序代写 python ”’

”’
/****************************************************************************************************/
/* #This is solution v1.0 (basic) the the mock test 1 */
/* #Author: Dr. Adrian Euler */
/* #Module: SMM283 – Introduction to Python */

Tested with Python 3.7 and 3.8 and 3.9
*/
/****************************************************************************************************/
”’
##AS AN EXERCISE, YOU MAY IMPROVE VARIOUS ASPECTS OF THE PROGRAM
import math as m
def pmt(rate, nper, pv, fv =0, itype = 0):
pmt_ = (pv*rate*(1+rate)**nper – fv)/((1+rate*itype)*(1+rate)**nper – 1)
return pmt_
def nfc(rate, nper, cost, cf = []):
fv_, j = (0.0, 0)
for i in range(1, nper+1):
fv_ += cf[j] * m.pow((1+rate), (nper – i))
j += 1
fv_ -= cost*m.pow((1+rate), nper)
return fv_
def main():
while True:
try:
rate = float(input(‘rate:= ‘))
if rate <0.0 or rate > 1.0:
continue
break
except:
‘~~~’
while True:
try:
nper =int(input(‘nper:= ‘))
if nper < 0: continue break except: '~~~' while True: try: pv = float(input('pv:= ')) if pv < 0.0: continue break except: '' while True: try: fv = float(input('fv:= ')) if fv < 0.0: continue break except: '~~~' while True: try: cost = float(input('cost:= ')) if cost < 0.0: continue break except: '~~~' print('Payment per term:= {0:>10s}’.format(‘£’+str(round(pmt(rate, nper, pv), 2))))
cf = []
while True:
try:
for i in range(nper):
temp = float(input(‘Enter cash flow at time node ‘ + str(i+1) + ‘: ‘))
cf.insert(i, temp)
0.023
break
except:
‘~~~’
print(‘Net future value:={0:>10s}’.format(‘£’ + str(round(nfc(rate, nper, cost, cf), 2))))
#——————————————————————————————————–
main()