ime_3/06 - Seleção/monteCarlo.py

17 lines
364 B
Python
Raw Normal View History

2022-03-15 23:34:21 +01:00
import turtle
import random
wn = turtle.Screen()
wn.setworldcoordinates(-1, -1, 1, 1)
fred = turtle.Turtle()
fred.up()
numdarts = 10
for i in range(numdarts):
x = random.random() if random.randrange(2) == 0 else -random.random()
y = random.random() if random.randrange(2) == 0 else -random.random()
fred.goto(x, y)
fred.stamp()
wn.exitonclick()