Draw a Fish Using Python Turtle

Draw Fish Using Python Turtle

Introduction

If you’re looking for a tutorial on how to draw a fish in Python Turtle, you’ve come to the correct spot. In this lesson, I’ll teach you how to design a fish in Python Turtle, so stick with me till the finish.

To draw fish in Python, we will use the turtle module. It is a Python GUI package that may be used to create characters, cartoons, shapes, and other things.

If you are unfamiliar with Python, drawing a fish might be challenging, but don’t worry, I will explain everything and supply you with the code for this application.

1. You only need to import the turtle library that comes with Python; no extra installation is required.

import turtle

2. The next step is to prepare a canvas on which to draw the fish. We can name the canvas variable whatever we want. For the time being, the screen’s name is vatsal. The code below generates and displays the screen for the user. We’ve also added some new properties, such as the color of the screen and the pen.

import turtle
vatsal = turtle
vatsal.color('black')
vatsal.Screen().bgcolor("#a2a2d0")
vatsal.pensize(10)

3. Let us now write a function that will draw the fish for us.


#Functions Which we will use
#goto(); function takes the pointer to a certain position.
#penup() and pendown() function controls when to draw and when to not draw
# forward() and backward() function needs the distance as a parameter
#left() and right() function needs an angle of turning as a parameter.

def Draw_Fish(i,j):
    vatsal.penup()
    vatsal.goto(i,j)
    vatsal.speed(10)
    vatsal.left(45)
    vatsal.pendown()
    vatsal.forward(100)
    vatsal.right(135)
    vatsal.forward(130)
    vatsal.right(130)
    vatsal.forward(90)
    vatsal.left(90)
    vatsal.right(90)
    vatsal.circle(200,90)
    vatsal.left(90)
    vatsal.circle(200,90)
    vatsal.penup()
    vatsal.left(130)
    vatsal.forward(200)
    vatsal.pendown()
    vatsal.circle(10,360)
    vatsal.right(270)
    vatsal.penup()
    vatsal.forward(50)
    vatsal.pendown()
    vatsal.left(90)
    vatsal.circle(100,45)
    vatsal.penup()
    vatsal.forward(300)
    vatsal.left(135)
    vatsal.pendown()
    vatsal.right(180)

4. Let’s use the code below to draw three fish on the screen. And once we’ve finished drawing the fish, we’ll use the done() function to close the application screen.


Draw_Fish(0,0)
Draw_Fish(150,150)
Draw_Fish(150,-150)
vatsal.done()

Complete code to Draw a Fish Using Python Turtle

import turtle
vatsal = turtle
vatsal.color('black')
vatsal.Screen().bgcolor("#a2a2d0")
vatsal.pensize(10)
 
def Draw_Fish(i,j):
    vatsal.penup()
    vatsal.goto(i,j)
    vatsal.speed(10)
    vatsal.left(45)
    vatsal.pendown()
    vatsal.forward(100)
    vatsal.right(135)
    vatsal.forward(130)
    vatsal.right(130)
    vatsal.forward(90)
    vatsal.left(90)
    vatsal.right(90)
    vatsal.circle(200,90)
    vatsal.left(90)
    vatsal.circle(200,90)
    vatsal.penup()
    vatsal.left(130)
    vatsal.forward(200)
    vatsal.pendown()
    vatsal.circle(10,360)
    vatsal.right(270)
    vatsal.penup()
    vatsal.forward(50)
    vatsal.pendown()
    vatsal.left(90)
    vatsal.circle(100,45)
    vatsal.penup()
    vatsal.forward(300)
    vatsal.left(135)
    vatsal.pendown()
    vatsal.right(180)
 
Draw_Fish(0,0)
Draw_Fish(150,150)
Draw_Fish(150,-150)
vatsal.done()

Output:

Draw a Fish Using Python Turtle

Congratulations! You now understand how to draw a fish on the screen in Python using the Turtle module.

If you want to see more amazing turtle tutorials like this one, go here: Python Turtle Codes.

If you don’t want to create all of the files and folders, you can run this program now with this online Python compiler, which is quick and easy.


Also Read:


Share:

Author: Vatsal Rakholiya