Draw Square using Python..🐍

Hello People,

In this Blog article, we will learn how to Draw a Square. We will see the implementation in Python.

Check out the Repository in python . Drop a star if you find it useful!!!

We are going to learn how to draw a square using Python Turtle Graphics by making use of functions of the turtle module.

Turtle is an inbuilt Python library that enables users to create simple graphics and shapes by providing them with a virtual canvas. Here’s my code that creates a square using a turtle.

Video on YouTube:

Code:


# Import the turtle module
import turtle as t

turtle = t.Turtle()

# For loop for repeating same line for 4 times.
for _ in range(4):
    turtle.forward(100)
    turtle.left(90)

# Screen() method in the turtle module is used to get the screen open.
screen = t.Screen()

# exit the screen after a simple left click.
screen.exitonclick()

Output:

Capture2.PNG

Thank you.

See you in my next Blog article, Take care!!

Dhruvin Gajjar.

TheCreators

Resources: