Demo entry 6340508

py

   

Submitted by anonymous on Dec 28, 2016 at 12:30
Language: Python 3. Code size: 782 Bytes.

import math
import turtle

def line(t,l,Ecke):
    t.fd(l)
    ecke = 180-Ecke
    t.lt(ecke)

def dreiecke(t,angle_ding,angle_di,r,length):
    line(t,r,angle_di)
    line(t,length,angle_di)
    line(t,r,angle_ding)

def polygon(t,n,r):
    angle_ding = 360/n
    angle_di = 90-180/n
    length = 2*r*math.sin(angle_ding/2*2*math.pi/360)

    angle_rotate = angle_ding/2
    t.lt(angle_rotate)

    for i in range(n):
        dreiecke(t,angle_ding,angle_di,r,length)
        t.lt(angle_ding)

    t.rt(angle_ding/2)
    
def move(t,weg):
    t.pu()
    t.fd(weg)
    t.pd()


bob = turtle.Turtle()

move(bob,-250)
polygon(bob,5,100)

move(bob,250)
polygon(bob,6,100)

move(bob,250)
polygon(bob,7,100)

bob.hideturtle()
turtle.mainloop()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).