|  | 
 
| 
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  复制代码from random import random,seed
hits = 0.0
DARTS = eval(input())
seed(123)
for i in range(DARTS):
    x,y = random(),random()
    dist = pow(x**2,y**2,0.5)
    if dist <= 1.0:
        hits = hits + 1
pi = 4*(hits/DARTS)
print("{:.6f}".format(pi))
1.你这个代码在哪照抄的?2.Traceback (most recent call last):
 File "C:\Users\Administrator\Desktop\006.py", line 8, in <module>
 dist = pow(x**2,y**2,0.5)
 TypeError: pow() 3rd argument not allowed unless all arguments are integers
 这是你的报错,我帮你翻译一下,在第8行代码pow ()第3个参数不允许,除非所有参数都是整数。
 3.下次最好说一下出处。
 | 
 |