Write Happy Halloween in Python Turtle

Write Happy Halloween in Python Turtle

Introduction

Hello, in this article we will see how to Write Happy Halloween in Python Turtle which is a library of python. Turtle lets us handle graphics very easily and smoothly. We will initially make the background color black, then we will write Happy Halloween and at last, we will draw some colored circles to make our design beautiful. We will understand the code line-by-line with the help of comments and in the end, the output is shown for the code. Click here to know about Halloween.

Code to Write Happy Halloween in Python Turtle

# importing libraries
import turtle
# initalizing a variable for turtle
t = turtle.Turtle()
# creating turtle screen
screen = turtle.Screen()
# setting up the screen size of canvas
screen.setup(1200, 600)
# changing the color of background to black
screen.bgcolor('black')
t.pencolor("red")
t.penup()
t.goto(-500, -20)
# defining font size, color and type
t.write('Happy Halloween', font=("Courier", 80, "italic"))
# from here we are adding colourful circles on our canvas
# deciding the color for circle
t.fillcolor("blue")
# start the filling color
t.begin_fill()
# radius of circle
r = 10
t.goto(100, 100)
t.circle(r)
# end filling the colour
t.end_fill()

# making different circles and different positions for different colours
t.fillcolor("white")
t.begin_fill()
t.goto(-100, -100)
t.circle(r)
t.end_fill()

t.fillcolor("green")
t.begin_fill()
t.goto(-200, -200)
t.circle(r)
t.end_fill()

t.fillcolor("orange")
t.begin_fill()
t.goto(100, -100)
t.circle(r)
t.end_fill()

t.fillcolor("yellow")
t.begin_fill()
t.goto(-100, 100)
t.circle(r)
t.end_fill()

t.fillcolor("pink")
t.begin_fill()
t.goto(-250, -150)
t.circle(r)
t.end_fill()

t.fillcolor("white")
t.begin_fill()
t.goto(-250, 150)
t.circle(r)
t.end_fill()

t.fillcolor("blue")
t.begin_fill()
t.goto(250, -150)
t.circle(r)
t.end_fill()

t.fillcolor("yellow")
t.begin_fill()
t.goto(-300, -200)
t.circle(r)
t.end_fill()

# holding the screen
screen.mainloop()

Output:

Output to Write Happy Halloween in Python Turtle

Also Read:

Share:

Author: Ayush Purawr