This commit is contained in:
Oliver Hofmann
2024-09-23 13:22:12 +02:00
commit 45c4160142
69 changed files with 1906 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
# Sophia läuft 100 Schritte nach vorne
from turtle import Turtle
sophia = Turtle()
sophia.forward(100)
sophia.screen.mainloop()
+14
View File
@@ -0,0 +1,14 @@
# Sophia zeichnet eine gestrichelte Linie
from turtle import Turtle
sophia = Turtle()
sophia.hideturtle()
for _ in range(10):
sophia.penup()
sophia.forward(5)
sophia.pendown()
sophia.forward(5)
sophia.screen.mainloop()
+22
View File
@@ -0,0 +1,22 @@
# Sophia zeichnet eine farbige Linie
from turtle import Turtle
sophia = Turtle()
sophia.pensize(5)
sophia.pencolor('green')
sophia.forward(30)
sophia.pencolor('blue')
sophia.forward(30)
sophia.pencolor('red')
sophia.forward(30)
sophia.pencolor('white')
sophia.forward(30)
sophia.pencolor('black')
sophia.forward(30)
sophia.pencolor('#c72426')
sophia.forward(30)
sophia.screen.mainloop()
+12
View File
@@ -0,0 +1,12 @@
# Nutzung von RGP-Farben in Turtle-Grafiken
from turtle import Turtle
sophia = Turtle()
sophia.pensize(50)
sophia.screen.colormode(255) # RGB-Farben aktivieren
sophia.pencolor(199, 36, 38)
sophia.forward(50)
sophia.screen.mainloop()
+14
View File
@@ -0,0 +1,14 @@
# Zeichnen eines Quadrats mit der Turtle
from turtle import Turtle
sophia = Turtle()
# Sophia zeichnet ein Quadrat
def draw_square():
for _ in range(4):
sophia.forward(100)
sophia.right(90)
draw_square()
sophia.screen.mainloop()
+14
View File
@@ -0,0 +1,14 @@
# Zeichnen eines Quadrats variabler Größe mit der Turtle
from turtle import Turtle
sophia = Turtle()
# Eine Turtle zeichnet ein Quadrat
def draw_square(turtle, length):
for _ in range(4):
turtle.forward(length)
turtle.right(90)
draw_square(sophia, 100)
sophia.screen.mainloop()
+21
View File
@@ -0,0 +1,21 @@
# Zeichnen eines gefüllten Quadrats mit der Turtle
from turtle import Turtle
# Eine Turtle zeichnet ein Quadrat
def draw_square(turtle, length):
for _ in range(4):
turtle.forward(length)
turtle.right(90)
# Eine Turtle zeichnet ein gefülltes Quadrat
def draw_filled_square(turtle, length):
turtle.begin_fill()
draw_square(turtle, length)
turtle.end_fill()
sophia = Turtle()
sophia.fillcolor('red')
draw_filled_square(sophia, 100)
sophia.screen.mainloop()
@@ -0,0 +1,23 @@
# Eine Turtle erhält eine Methode zum Zeichnen eines gefüllten Quadrats
from turtle import Turtle
# Eine Turtle zeichnet ein Quadrat
def draw_square(turtle, length):
for _ in range(4):
turtle.forward(length)
turtle.right(90)
#
def draw_filled_square(turtle, length):
turtle.begin_fill()
draw_square(turtle, length)
turtle.end_fill()
# Eintragen der Methode draw_filled_square
Turtle.draw_filled_square = draw_filled_square
sophia = Turtle()
sophia.fillcolor('red')
sophia.draw_filled_square(100)
sophia.screen.mainloop()
+7
View File
@@ -0,0 +1,7 @@
from turtle import Turtle
sophia = Turtle()
sophia.write('Hello, World!', align='center', font=('Arial', 24, 'bold'))
sophia.screen.mainloop()
+18
View File
@@ -0,0 +1,18 @@
from turtle import Turtle
sophia = Turtle()
def draw_h(turtle):
turtle.left(90)
turtle.forward(100)
turtle.backward(50)
turtle.right(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.backward(100)
turtle.right(90)
draw_h(sophia)
sophia.screen.mainloop()