Personal tools
You are here: o studio 110 2016-17 tmp Inf 11 doku doku s py s upload Wabe2.py

Wabe2.py

Johannes

Wabe2.py — Python Source, 1Kb

File contents

# Python für Kids - 4. Auflage

# Autor: Gregor Lingl
# Datum 4. 8. 2009
# wabe.py - Kapitel 2: Aufgabe 4 

from turtle import *


reset()

farben=("yellow","green", "cyan","orange","red","brown","blue","black",)

def a(n,m,o):
  penup()
  pendown()
  pensize(0)
  pencolor("white")
  fillcolor(farben[m])
  begin_fill()
  forward(4)
  left(60)
  forward(4)
  left(60)
  forward(4)
  left(60)
  forward(4)
  left(60)
  forward(4)
  left(60)
  forward(4)
  left(60)
  end_fill()
  for i in range(n):
    fillcolor(farben[o])
    pendown()

    begin_fill()
    forward(4)
    right(60)
    forward(4)
    right(60)
    forward(4)
    right(60)
    forward(4)
    right(60)
    forward(4)
    right(60)
    forward(4)
    right(60)
    end_fill()
    penup()
    forward(4)
    left(60)


def b(x):
    for i in range(x):
      n=i*6
      a(n)
      left(245)
      forward(25)

def u(laufe):
    m=1
    o=5
    p=1
    for i in range(laufe):
      pencolor("white")
      setheading(90)
      if p==1:
          z=1
      else:
        z=p*2
      penup()
      forward(p*20)
      pendown()
      for i in range(z*5):
          a(6,m,o)
          left(222)
          forward(z*20)
      if ((len(farben)-1)>m):
          m=m+1
      else:
          m=0
      if ((len(farben)-1)>o):
          o=o+1
      else:
          o=0
      home()
      p=p+1
      

u(10)
Document Actions