Search code examples
pythonturtle-graphicspython-turtle

How to make a frowning face on Python Turtle?


I need to make a frowning turtle face in python however I can't get the semi-circle arc like frown right, it's too big or not complete.

import turtle
t = turtle.Turtle(2)
t.speed(5)
t.forward(120)
t.left(105)
t.forward(130)
t.right(90)
t.forward(25)
t.right(80)
t.forward(140)
t.left(65)
t.forward(100)
t.right(30)
t.forward(30)
t.right(30)
t.forward(30)
t.right(70)
t.forward(30)
t.right(30)
t.forward(30)
t.right (20)
t.forward(80)
t.left(65)
t.forward(130)
t.right(90)
t.forward(25)
t.right(80)
t.forward(110)
t.left (105)
t.forward (160)
t.left(65)
t.forward(50)
t.right(90)
t.forward(25)
t.right(80)
t.forward(60)
t.left (105)
t.right(65)
t.forward(70)
t.right(90)
t.forward(25)
t.right(80)
t.forward(32)
t.left (55)
t.forward(60)
t.penup()
t.right(90)
t.forward(20)
t.pendown()
r = 15
t.circle(r)
t.penup()
t.left(90)
t.forward(10)
t.left(90)
t.forward(5)
t.pendown()
r = 2
t.circle(r)
t.penup()
t.right(90)
t.forward(10)
t.pendown()
r = 2
t.circle(r)
t.penup()
t.forward(5)
t.right(90)
t.forward(15)
t.pendown()
for x in range(180):
    t.forward(1)
    t.right(1)
t.left(90)

This is my code so far


Solution

  • Rather than using an explicit loop, we can use the circle() method again to draw the frown. In this case we need to add the optional extent argument, and also learn what using positive and negative radii and extents does to circle().

    Below is my example solution where I've tossed your initial airplane drawing just to focus on the face:

    import turtle
    
    t = turtle.Turtle()
    
    # head
    r = 15
    t.right(90)
    t.circle(r)
    
    r = 2
    
    # right eye
    t.penup()
    t.left(90)
    t.forward(10)
    t.left(90)
    t.forward(5)
    t.pendown()
    t.circle(r)
    
    # left eye
    t.penup()
    t.right(90)
    t.forward(10)
    t.right(90)
    t.pendown()
    t.circle(r)
    
    # frown
    r = 5
    t.penup()
    t.left(90)
    t.backward(5)
    t.right(90)
    t.forward(10)
    t.left(90)
    t.circle(-r, 60)
    t.pendown()
    t.circle(-r, -120)
    
    t.hideturtle()
    turtle.done()