Ребята помогите пожалуйста картинка гриба с помощю кода в Python если не знаете ответ не пишите
Ответы
Ответ:
from turtle import *
def drawCircle(t, radius, input_color):
''' draw a circle of specified radius and color'''
t.color(input_color)
t.pensize(5)
t.circle(radius)
def fillCircle(t, radius, border_color, fill_color):
'''fill a circle with specified radius and border color/fill color'''
t.begin_fill ()
drawCircle (t, radius, border_color)
t.fillcolor (fill_color)
t.end_fill ()
def drawArc(t, radius, degree, fill_color):
'''draw a semicircle with specific radius, arc, and fill color'''
t.begin_fill()
t.circle(radius, degree) # ??? I'm not sure if it is right.
t.fillcolor (fill_color)
t.end_fill()
def drawRectangle(t, length, width, fill_color):
'''draw a triangle with specified lenght and color'''
t.begin_fill()
t.color (fill_color)
t.fd (length)
t.lt (90)
t.fd (width)
t.lt (90)
t.fd (length)
t.lt (90)
t.fd (width)
t.fillcolor (fill_color)
t.end_fill()
def initDraw (pen_shape, pen_size, pen_color, pen_speed):
'''create a turtle object with specific parameters '''
t.shape (pen_shape)
t.pensize(pen_size)
t.color (pen_color)
t.speed (pen_speed)
def draw(t):
'''functions to draw a mushroom'''
drawArc(t, radius, degree, fill_color)
drawRectangle(t, length, width, fill_color)
fillCircle(t, radius, border_color, fill_color)
# test driver code
t = Turtle()
initDraw("turtle", 3, "red", 10)
t.up()
t.goto(135, 60)
t.lt(100)
t.down ()
drawArc(t, 160, 160, "red")
t.up()
t.goto(-50, 59)
t.lt(10)
t.down ()
drawRectangle(t, 150, 60, "yellow")
t.up()
t.goto(-120, 100)
t.lt(10)
t.down ()
fillCircle(t, 12, "white", "white")
t.up()
t.goto(90, 100)
t.lt(10)
t.down ()
fillCircle(t, 12, "white", "white")
t.up()
t.goto(-30, 120)
t.lt(10)
t.down ()
fillCircle(t, 12, "white", "white")
t.up()
t.goto(-90, 150)
t.lt(10)
t.down ()
fillCircle(t, 12, "white", "white")
t.up()
t.goto(40, 150)
t.lt(10)
t.down ()
fillCircle(t, 12, "white", "white")
t.up()
t.goto(- 170, -200)
t.down ()
initDraw("turtle", 3, "blue", 10)
t.write ("Hi, I am the proud creation of this mushroom :o", font=("Calibri", 14, "normal"))
t.up()
initDraw("turtle", 3, "red", 10)
t.goto (-230, -230)
t=initDraw()
draw(t)
exitonclick()