Yellow Heart using Python ♥

Code :

import turtle

t = turtle.Turtle()

t.shapesize(0.2, 0.2)

s = turtle.Screen()

s.bgcolor('black')

t.fillcolor("yellow")

t.begin_fill()

t.left(50)

t.forward(240)

t.circle(90, 200)

t.left(221)

t.circle(90, 200)

t.forward(260)

t.end_fill()

turtle.done()

#clcoding.com

Explanation:

This code utilizes the Turtle module in Python to create a graphic using turtle graphics. Let's break down each part of the code:

import turtle: This line imports the Turtle module, which provides a drawing canvas and various methods for creating graphics using turtle graphics.

t = turtle.Turtle(): This creates a turtle object named t. The turtle object represents a turtle that can move around the screen and draw lines and shapes.

t.shapesize(0.2, 0.2): This line sets the size of the turtle shape. The parameters 0.2, 0.2 specify that the turtle's shape should be scaled to 20% of its default size in both the x and y directions.

s = turtle.Screen(): This creates a screen object named s. The screen object represents the window or canvas where the turtle will draw.

s.bgcolor('black'): This sets the background color of the screen to black.

t.fillcolor("yellow"): This sets the fill color of the turtle to yellow.

t.begin_fill(): This marks the beginning of a shape that will be filled with the fill color.

t.left(50): This turns the turtle left by 50 degrees.

t.forward(240): This moves the turtle forward by 240 units.

t.circle(90, 200): This draws a partial circle with a radius of 90 units and an extent of 200 degrees. This creates a curved shape.

t.left(221): This turns the turtle left by 221 degrees.

t.circle(90, 200): This draws another partial circle similar to the previous one.

t.forward(260): This moves the turtle forward by 260 units.

t.end_fill(): This marks the end of the shape to be filled and fills the shape with the specified fill color.

turtle.done(): This keeps the window open after the drawing is complete until the user closes it manually.

This code creates a graphic consisting of two curved shapes filled with yellow color on a black background.