Ответы
import turtle
def draw_land():
# Set the color to a land-like color (e.g., 'saddlebrown')
turtle.color('saddlebrown')
# Put the turtle at the start position for the land
turtle.penup()
turtle.goto(-300, -100) # You can adjust these coordinates as needed
turtle.pendown()
turtle.begin_fill() # Begin filling in the drawn shape
# Draw a rectangle
for _ in range(2):
turtle.forward(300) # The forward distance here sets the width of the land
turtle.right(90)
turtle.forward(5) # The forward distance here sets the thickness of the land
turtle.right(90)
turtle.end_fill() # End filling in the land. Fills the last drawn shape
def draw_tree():
# Draw trunk
turtle.color("brown")
turtle.begin_fill()
turtle.forward(140)
for _ in range(2):
turtle.forward(20)
turtle.left(90)
turtle.forward(60)
turtle.left(90)
turtle.end_fill()
# Move to position for bottom triangle
turtle.left(90)
turtle.forward(60)
turtle.right(90)
turtle.forward(10)
# Draw first triangle (bottom)
turtle.color("green")
turtle.penup()
turtle.forward(50)
turtle.pendown()
turtle.left(120)
turtle.begin_fill()
for _ in range(3):
turtle.forward(100)
turtle.left(120)
turtle.end_fill()
# Move to position for top triangle (right above the bottom triangle)
# Set the turtle's y position to 100
turtle.left(40)
turtle.forward(50)
turtle.sety(30)
turtle.penup() # Make sure the pen is up to not draw lines
turtle.setheading(0)
turtle.forward(50)
turtle.pendown()
turtle.left(120)
turtle.begin_fill()
for _ in range(3):
turtle.forward(100)
turtle.left(120)
turtle.end_fill()
# Setup turtle
turtle.speed(5)
# Usage:
# Draw the land first...
draw_land()
# Draw tree
draw_tree()
# Hide turtle
turtle.hideturtle()
# End of drawing
turtle.done()