Skip to content
Related Articles

Related Articles

Draw a car using Turtle in Python
  • Difficulty Level : Expert
  • Last Updated : 01 Oct, 2020

Prerequisite: Turtle module, Drawing Shapes

There are many modules in python which depicts graphical illustrations, one of them is turtle, it is an in-built module in Python, which lets the user control a pen(turtle) to draw on screen(drawing board). It is mostly used to illustrate figures, shapes, designs etc.  In this article, we will learn how to draw a Car using the turtle module. 

To draw a car in Python using Turtle module:

  1. We are going to create different shapes using the turtle module in-order to illustrate a car.
  2. Tyres can be drawn using circle() function.
  3. The upper body can be thought of a rectangle.
  4. Roof and windows are similar to trapezoid.
  5. Overlapping all the above shapes in particular positions will illustrate a car.  

 Let’s try to understand it better with the help of the below program:

Python3



filter_none

edit
close

play_arrow

link
brightness_4
code

#Python program to draw car in turtle programming
  
# Import required library 
import turtle
   
    
car = turtle.Turtle()
  
  
# Below code for drawing rectangular upper body
car.color('#008000')
car.fillcolor('#008000')
car.penup()
car.goto(0,0)
car.pendown()
car.begin_fill()
car.forward(370)
car.left(90)
car.forward(50)
car.left(90)
car.forward(370)
car.left(90)
car.forward(50)
car.end_fill()
   
    
# Below code for drawing window and roof
car.penup()
car.goto(100, 50)
car.pendown()
car.setheading(45)
car.forward(70)
car.setheading(0)
car.forward(100)
car.setheading(-45)
car.forward(70)
car.setheading(90)
car.penup()
car.goto(200, 50)
car.pendown()
car.forward(49.50)
   
    
# Below code for drawing two tyres
car.penup()
car.goto(100, -10)
car.pendown()
car.color('#000000')
car.fillcolor('#000000')
car.begin_fill()
car.circle(20)
car.end_fill()
car.penup()
car.goto(300, -10)
car.pendown()
car.color('#000000')
car.fillcolor('#000000')
car.begin_fill()
car.circle(20)
car.end_fill()
   
    
car.hideturtle()

chevron_right


Output:


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :