我得到了一个函数,它可以画圆并随机回答
(这里的答案是1-100之间的数字)
def circle(x,y,ans):
#RandomAnswer
global RaAns
RaAns = random.randint(1, 100)
tr.up()
#center of circle is: (x,y)
tr.goto(x,y-40)
tr.down()
tr.fill(1)
tr.color(0.2,0.2,0.2)
tr.circle(40)
tr.color(0.2,0.6,0.6)
tr.fill(0)
tr.up()
tr.goto(x-15,y-15)
tr.down()
tr.color(0.2,0.2,0.2)
tr.write(RaAns,font=("Ariel",20))
我也明白了:
C1 = circle(150,245,RaAns)
C2 = circle(245,150,RaAns)
我的问题是如何选择C1RaAns
和C2RaAns
?你知道吗
你不能,他们被重新分配了一个新号码。也就是说,当get
C2
时,RaAns
被重新分配。您应该这样做,要么返回raan,要么完全放弃它并使用ans
参数。你知道吗如果您必须返回其他内容,请预先生成随机数。你知道吗
相关问题 更多 >
编程相关推荐