How to fix this python program?
Posted
by Phenom
on Stack Overflow
See other posts from Stack Overflow
or by Phenom
Published on 2010-04-17T05:08:19Z
Indexed on
2010/04/17
5:13 UTC
Read the original article
Hit count: 260
python
import math
def p(n):
return 393000*((288200/393000)^n * math.exp(-(288200/393000)))/math.factorial(n)
print p(3)
When I run it, I get the following error message:
Traceback (most recent call last):
File "poisson.py", line 6, in <module>
print p(3)
File "poisson.py", line 4, in p
return 393000*((288200/393000)^n * math.exp(-(288200/393000)))/math.factoria
l(n)
TypeError: unsupported operand type(s) for ^: 'int' and 'float'
© Stack Overflow or respective owner