Traceback (most recent call last):
File "E:/code/python/pycharm/wangyi_5.py", line 43, in
simFlips(100,100)
File "E:/code/python/pycharm/wangyi_5.py", line 20, in simFlips
heads,tails=flipTrial(numFlips)
File "E:/code/python/pycharm/wangyi_5.py", line 12, in flipTrial
coin=random.randint(0,1)
AttributeError: 'builtin_function_or_method' object has no attribute 'randint'
import random
import math
from pylab import *
def flipTrial(numFlips):
heads,tails=0,0
for i in xrange(0,numFlips):#xrange进行示例时不用建表,依次执行结果,比rang节省空间
coin=random.randint(0,1)
if coin==0:heads +=1
else:tails+=1
return heads,tails