Python and Turtle Difficulty Level 2,Tutorial Tutorial: How to Draw Football Shape with Python Turtle

Tutorial: How to Draw Football Shape with Python Turtle

In this tutorial we are going show you how to draw a basic football shape with Python’s Turtle graphics library. As seen in the next figure, football shape has two sections: red section and blue section. We are going to draw each section one by one.

Two sections of football shape

To draw the red section, we need to lift up the pen and goto the red dot and use Turtle’s circle function to draw an arc. The degree of the arc can vary, but 90 degree works good. Turtle’s pen will turn 90 degrees counter-clock wise after drawing this arc. If we set the initial heading of the pen to -45 degrees, the heading of the pen will end up to be 45 degrees after drawing the 90 degree arc – a perfect symmetry! The following is the code snippet for drawing the red arc:

r = 500
turtle.up()
turtle.goto(-r/2**0.5,0)
turtle.seth(-45)
turtle.down()
turtle.color('red')
turtle.circle(r,90)
Red Arc

The blue arc can be drawn in the similar way. The first step is to set the heading of Turtle’s pen to 135 (135 = 90 + 45) degree first and draw the 90 degree arc with circle function. The following is the code snippet:

turtle.seth(135)
turtle.color('blue')
turtle.circle(r,90)
Blue Arc

Related Post