Draw Ellipse Using Turtle in Python
Last Updated :
29 Sep, 2021
Prerequisite: Turtle Programming Basics
Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc.
Approach:
The following steps are used :
- Import turtle
- Divide the ellipse into four arcs
- Define a method to form these arc in pair
- Call the function.
Below is the implementation :
Python3
import turtle
def draw(rad):
for i in range ( 2 ):
turtle.circle(rad, 90 )
turtle.circle(rad / / 2 , 90 )
turtle.seth( - 45 )
draw( 100 )
|
Output :
Draw design using ellipse Shape
The following steps are used :
- Import turtle
- Set Screen
- Divide the ellipse into four arcs
- Define a method to form these arc in pair
- Call the function multiple times for different colors.
Below is the implementation :
Python3
import turtle
screen = turtle.Screen()
def draw(rad):
for i in range ( 2 ):
turtle.circle(rad, 90 )
turtle.circle(rad / / 2 , 90 )
screen.setup( 500 , 500 )
screen.bgcolor( 'black' )
col = [ 'violet' , 'blue' , 'green' , 'yellow' ,
'orange' , 'red' ]
val = 10
ind = 0
turtle.speed( 100 )
for i in range ( 36 ):
turtle.seth( - val)
turtle.color(col[ind])
if ind = = 5 :
ind = 0
else :
ind + = 1
draw( 80 )
val + = 10
turtle.hideturtle()
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...