Correzione PEP8

This commit is contained in:
Rnhmjoj 2013-08-25 19:41:29 +02:00
parent 73d34a5cc0
commit 9b41419afb

View File

@ -6,35 +6,39 @@ import turtle
X = 100
Y = 100
T = 20
L = 5/6*T
L = 5 / 6 * T
N = 213
assi = ()
def impostazioni():
"""Impostazioni per inizializzare turtle"""
turtle.title("Ago di Buffon")
turtle.setworldcoordinates(-(X+2), -(Y), X+2, Y)
turtle.setworldcoordinates(-(X + 2), -(Y), X + 2, Y)
turtle.hideturtle()
turtle.speed(0)
def vai(x, y):
"""Sposta il cursore al punto (x, y) senza tracciare una linea."""
turtle.pu()
turtle.goto(x, y)
turtle.pd()
def parquet(t):
"""Disegna le assi del parquet."""
global X, assi
vai(-X, -Y)
for x in range(-X, X+1, t):
for x in range(-X, X + 1, t):
assi += x,
turtle.lt(90)
turtle.goto(x, Y)
vai(x, -Y)
turtle.rt(90)
vai(x+t, -Y)
vai(x + t, -Y)
def ago(l):
"""
@ -62,10 +66,10 @@ p = 0
for i in range(N):
p += ago(L)
try:
π = (2*L)/(T*p/N)
π = (2 * L) / (T * p / N)
except ZeroDivisionError:
π = 0
print(π)
print("Scarto:", abs(100-(π/math.pi*100)), "%")
print("Scarto:", abs(100 - (π / math.pi * 100)), "%")
turtle.mainloop()