View Single Post
Old 16-01-2008, 16:54   #1
Occasus
Member
 
L'Avatar di Occasus
 
Iscritto dal: May 2005
Cittā: Another World
Messaggi: 237
[Python] Aiuto esercizio di "How to Think Like a Python Programmer"

Ciao a tutti.
Dopo diversi fallimenti, sto tentando di imparare qualcosa su un linguaggio di programmazione, in questo caso il Python.
http://www.greenteapress.com/thinkpy...005.html#toc50 , esercizio 3.

Avendo giā a disposizione queste funzioni:
Codice:
import math
from TurtleWorld import *
TurtleWorld()
bob = Turtle()
bob.delay = 0.01

def polyline(t, length, n, angle):
    """Draw n line segments with the given length and
    angle (in degrees) between them. t is a turtle.
    """
    for i in range(n):
        fd(t, length)
        lt(t, angle)

def arc(t, r, angle):
    """Draw an arc with the given r (radius) and angle
    """(in degrees). t is a turtle.
    arclength = 2 * math.pi * r * angle / 360
    n = int(arclength / 4)
    length = arclength / n
    polyline(t, length, n, float(angle)/n)
come posso fare a realizzare la funzione per disegnare i fiori?

L'unica cosa funzionante che sono riuscito a fare č la definizione della funzione:
Codice:
def flower(t, r, petals):


Grazie per l'aiuto.
Occasus č offline   Rispondi citando il messaggio o parte di esso