Introduction
Hello and thank you for visiting violet-cat-415996.hostingersite.com. We’ll look at how to Draw Car using Python Turtle in this post. This will be a brief but informative post, especially for beginners, because we have commented on every line of code so that even a rookie can understand the concept.
The car will be constructed in stages. We’ll start at the bottom left and work our way up, drawing the composite shapes that make up the car until we’re finished.
To draw a car with Python Turtle, you must think of it in terms of particular shapes. Tyers can be drawn using the rectangle forward function. The upper body of a car can be thought of as a rectangle. And roof and window are drawn using slanted lines.
1. To begin, we’ll import the Python Turtle module, execute the delay function, and increase the turtle’s pen size.
import turtle
vatsal = turtle.Turtle()
turtle.delay(10)
vatsal.pensize(7)
turtle.Screen().bgcolor("#F5F5DC")
vatsal.speed(10)
2. After that, we’ll move the turtle to the far left. We want to draw with a scale factor of 25, therefore we’ll double whatever coordinate we obtain by 25.
# Move the turtle to the extreme left position
vatsal.penup()
vatsal.setposition(-200,-75)
3. Now you should create a rectangle with a length of 400 and a width of 150.
# Draw the rectangle
vatsal.fillcolor("#46523C")
vatsal.begin_fill()
vatsal.pendown()
vatsal.forward(400)
vatsal.setheading(90)
vatsal.forward(150)
vatsal.setheading(180)
vatsal.forward(400)
vatsal.setheading(-90)
vatsal.forward(150)
vatsal.end_fill()
4. Now We are going to draw the tyers.
# Draw the left tire
vatsal.fillcolor("black")
vatsal.begin_fill()
vatsal.penup()
vatsal.setposition(-175,-75)
vatsal.pendown()
vatsal.forward(50)
vatsal.setheading(0)
vatsal.forward(75)
vatsal.setheading(90)
vatsal.forward(50)
vatsal.end_fill()
# Draw the right tire
vatsal.penup()
vatsal.setposition(100,-75)
vatsal.fillcolor("black")
vatsal.begin_fill()
vatsal.pendown()
vatsal.setheading(270)
vatsal.forward(50)
vatsal.setheading(0)
vatsal.forward(75)
vatsal.setheading(90)
vatsal.forward(50)
vatsal.end_fill()
5. Now we’re going to draw the top line.
# Draw the uppermost line
vatsal.penup()
vatsal.setposition(-137.5,200)
vatsal.pendown()
vatsal.setheading(0)
vatsal.forward(275)
6. The second topmost line will be drawn next.
# Draw the second uppermost line
vatsal.penup()
vatsal.setposition(-150,150)
vatsal.pendown()
vatsal.setheading(0)
vatsal.forward(300)
7. The left and right slanting lines must be drawn to complete the shape of the car.
Simply draw a line from the uppermost line’s tip to where the left-slanting line should contact the rectangle to create the left-slanting line.
# Draw the left slanted line
vatsal.penup()
vatsal.setposition(-137.5,200)
vatsal.pendown()
vatsal.setposition(-175,75)
# Draw the right slanted line
vatsal.penup()
vatsal.setposition(137.5,200)
vatsal.pendown()
vatsal.setposition(175,75)
8. We can now sketch the car properly. The headlights will be adjusted initially. First, we create a circle for the left headlight and then a circle for the right headlight.
# Draw the left circle
vatsal.penup()
vatsal.setposition(-125,-25)
vatsal.pendown()
vatsal.fillcolor("#ECFFDC")
vatsal.begin_fill()
vatsal.circle(25)
vatsal.end_fill()
# Draw the right circle
vatsal.penup()
vatsal.setposition(125,-25)
vatsal.pendown()
vatsal.fillcolor("#ECFFDC")
vatsal.begin_fill()
vatsal.circle(25)
vatsal.end_fill()
9. Now the wipers are to be drawn. The left wiper will be drawn first, followed by the second wiper.
# Draw the left wiper
vatsal.penup()
vatsal.setposition(-87.5, 75)
vatsal.pendown()
vatsal.setposition(-50, 112.5)
# Draw the right wiper
vatsal.penup()
vatsal.setposition(62.5, 75)
vatsal.pendown()
vatsal.setposition(100, 112.5)
10. Finally, the four horizontal lines are sketched.
# Draw the horizontal lines
vatsal.penup()
vatsal.setposition(-50, -37.5)
vatsal.pendown()
vatsal.setposition(-50, 0)
vatsal.penup()
vatsal.setposition(-15, -37.5)
vatsal.pendown()
vatsal.setposition(-15, 0)
vatsal.penup()
vatsal.setposition(15, -37.5)
vatsal.pendown()
vatsal.setposition(15, 0)
vatsal.penup()
vatsal.setposition(50, -37.5)
vatsal.pendown()
vatsal.setposition(50, 0)
Complete Code to Draw Car using Python Turtle
import turtle vatsal = turtle.Turtle() turtle.delay(10) vatsal.pensize(7) turtle.Screen().bgcolor("#F5F5DC") vatsal.speed(10) # Move the turtle to the extreme left position vatsal.penup() vatsal.setposition(-200,-75) # Draw the rectangle vatsal.fillcolor("#46523C") vatsal.begin_fill() vatsal.pendown() vatsal.forward(400) vatsal.setheading(90) vatsal.forward(150) vatsal.setheading(180) vatsal.forward(400) vatsal.setheading(-90) vatsal.forward(150) vatsal.end_fill() # Draw the left tire vatsal.fillcolor("black") vatsal.begin_fill() vatsal.penup() vatsal.setposition(-175,-75) vatsal.pendown() vatsal.forward(50) vatsal.setheading(0) vatsal.forward(75) vatsal.setheading(90) vatsal.forward(50) vatsal.end_fill() # Draw the right tire vatsal.penup() vatsal.setposition(100,-75) vatsal.fillcolor("black") vatsal.begin_fill() vatsal.pendown() vatsal.setheading(270) vatsal.forward(50) vatsal.setheading(0) vatsal.forward(75) vatsal.setheading(90) vatsal.forward(50) vatsal.end_fill() # Draw the uppermost line vatsal.penup() vatsal.setposition(-137.5,200) vatsal.pendown() vatsal.setheading(0) vatsal.forward(275) # Draw the second uppermost line vatsal.penup() vatsal.setposition(-150,150) vatsal.pendown() vatsal.setheading(0) vatsal.forward(300) # Draw the left slanted line vatsal.penup() vatsal.setposition(-137.5,200) vatsal.pendown() vatsal.setposition(-175,75) # Draw the right slanted line vatsal.penup() vatsal.setposition(137.5,200) vatsal.pendown() vatsal.setposition(175,75) # Draw the left circle vatsal.penup() vatsal.setposition(-125,-25) vatsal.pendown() vatsal.fillcolor("#ECFFDC") vatsal.begin_fill() vatsal.circle(25) vatsal.end_fill() # Draw the right circle vatsal.penup() vatsal.setposition(125,-25) vatsal.pendown() vatsal.fillcolor("#ECFFDC") vatsal.begin_fill() vatsal.circle(25) vatsal.end_fill() # Draw the left wiper vatsal.penup() vatsal.setposition(-87.5, 75) vatsal.pendown() vatsal.setposition(-50, 112.5) # Draw the right wiper vatsal.penup() vatsal.setposition(62.5, 75) vatsal.pendown() vatsal.setposition(100, 112.5) # Draw the horizontal lines vatsal.penup() vatsal.setposition(-50, -37.5) vatsal.pendown() vatsal.setposition(-50, 0) vatsal.penup() vatsal.setposition(-15, -37.5) vatsal.pendown() vatsal.setposition(-15, 0) vatsal.penup() vatsal.setposition(15, -37.5) vatsal.pendown() vatsal.setposition(15, 0) vatsal.penup() vatsal.setposition(50, -37.5) vatsal.pendown() vatsal.setposition(50, 0)
Output:
Also Read:
- Create your own ChatGPT with Python
- SQLite | CRUD Operations in Python
- Event Management System Project in Python
- Ticket Booking and Management in Python
- Radha Krishna using Python Turtle
- Hostel Management System Project in Python
- Sales Management System Project in Python
- Bank Management System Project in C++
- Python Download File from URL | 4 Methods
- Python Programming Examples | Fundamental Programs in Python
- Drawing letter A using Python Turtle
- Spell Checker in Python
- Portfolio Management System in Python
- Stickman Game in Python
- Contact Book project in Python
- Loan Management System Project in Python
- Cab Booking System in Python
- Brick Breaker Game in Python
- Wishing Happy New Year 2023 in Python Turtle
- Tank game in Python
- GUI Piano in Python
- Ludo Game in Python
- Rock Paper Scissors Game in Python
- Snake and Ladder Game in Python
- Puzzle Game in Python
- Draw Goku in Python Turtle
- Medical Store Management System Project in Python
- Draw Mickey Mouse in Python Turtle
- Creating Dino Game in Python
- Tic Tac Toe Game in Python