Files
inf-kswo/RandomTurtle/Eiskristall-Rekursion.py
Janis Hutz ede0ee318b Format
There really is no hope of making this code even half-way decent without
spending the time to rewrite them all properly. Don't want to do any of
that
2025-11-03 17:08:35 +01:00

40 lines
817 B
Python
Executable File

from turtle import *
import time
r = numinput("PENTAGON", "Wie gross soll die Seitenlänge des Pentagons sein?", 200)
rl = numinput("PENTAGON", "Wie viele Ebenen sollen benuzt werden?", 3)
tracer(0)
def pentagon(n, radius):
if n == 0:
# ausgefülltes Pentagon zeichnen
color("Red")
begin_fill()
for i in range(5):
fd(radius)
rt(360 / 5)
end_fill()
else:
for i in range(5):
# Positionierung der Turtle
pu()
fd(radius * 2.62 * 0.381966)
rt(360 / 5)
pd()
# Rekursion
pentagon(n - 1, radius * 0.381966)
update()
starttime = time.time()
pu()
lt(90)
fd(r)
rt(90)
bk(r * 0.6)
pd()
pentagon(rl, r)
exitonclick()