Rainbow by Turtle

An example for programming lessons at school

Rainbow by Turtle
import turtle t = turtle.Turtle() # Setting the title turtle.title("Rainbow by Turtle") t.hideturtle() # Setting the rainbow width rainbow_width = 20 t.width(rainbow_width+1) t.left(90) # Setting the rainbow radius r=50 angle=180 # Colors for the rainbow colors=["violet", "indigo", "blue", "green", "yellow", "orange", "red"] for i in colors: t.color(i) r=r+rainbow_width t.circle(r, angle) t.up() t.right(90) t.forward(rainbow_width) t.down() t.left(90) angle=angle*(-1) t.done()

Amongus by Turtle on Python

An example for programming lessons at school

Amongus by Turtle on Python
import turtle # Primary colors for the character BODY_COLOR = 'red' GLASS_COLOR = 'skyblue' # Setting the title turtle.title("Amongus by Turtle") # Main object Turtle t = turtle.Turtle() t.hideturtle() # Method for drawing the body def body(): # Brush size t.pensize(20) # Setting the color t.fillcolor(BODY_COLOR) t.begin_fill() # Right side t.right(90) t.forward(50) t.right(180) t.circle(40, -180) t.right(180) t.forward(200) # Head t.right(180) t.circle(100, -180) # Left side t.backward(20) t.left(15) t.circle(500, -20) t.backward(20) t.circle(40, -180) t.left(7) t.backward(50) t.up() t.left(90) t.forward(10) t.right(90) t.down() t.right(240) t.circle(50, -70) t.end_fill() # Method for drawing glasses def glass(): # Moving the turtle t.up() t.right(230) t.forward(100) t.left(90) t.forward(20) t.right(90) t.down() # Setting the color t.fillcolor(GLASS_COLOR) t.begin_fill() t.right(150) t.circle(90, -55) t.right(180) t.forward(1) t.right(180) t.circle(10, -65) t.right(180) t.forward(110) t.right(180) t.circle(50, -190) t.right(170) t.forward(80) t.right(180) t.circle(45, -30) t.end_fill() # Method for drawing a backpack def backpack(): # Moving the turtle t.up() t.right(60) t.forward(100) t.right(90) t.forward(75) # Setting the color t.fillcolor(BODY_COLOR) t.begin_fill() t.down() t.forward(30) t.right(255) t.circle(300, -30) t.right(260) t.forward(30) t.end_fill() # Call all necessary methods body() glass() backpack() turtle.done()