Syntax error in IPython 2.2.0 -
i'm running ipython 2.2.0 in anaconda on windows 8, , i'm running error code supposed find value of stock option.
here's code:
so = 100. k = 105. t = 1.0 r = 0.05 sigma = 0.2 numpy import * = 100000 z = random.standard_normal(i) st = * exp((r - 0.5 * sigma ** 2) * t + sigma * sqrt(t) * z) ht = maximum(st - k, 0) co = exp(-r * t) * sum(ht) / print "value of european call option %5.3f" % co
when run print command on last line, it's telling me it's invalid syntax , has arrow beneath second quotation mark (next %5.3f". ideas?
the problem print function. using python version allows print()
function....seems suggest ipython 2.2.0 using python 3.x version underneath (just guess, can wrong).
try following instead:
print("value of european call option %5.3f" % co)
this should work...
Comments
Post a Comment