🐢PYTHON TURTLE GRAPHICS🐢 | Check out the website in the description to understand the code🎨

Опубликовано: 02 Октябрь 2026
на канале: Roshni
28
2

Website link👇: https://roshnik.neocities.org/turtle_graph...

If you're new to programming or just love making creative things, you've come to the right place✨! This channel is dedicated to help you learn Python Turtle Graphics through fun and easy-to-understand projects.
We’ll walk through a basic Shape Drawing Program where you can draw circles, triangles, hearts, and more by simply answering a few popup prompts.

You’ll be able to draw multiple shapes on your screen with just a few clicks. No complex GUI needed — only pop-up inputs and your imagination🎨
You'll find the full code to try it yourself!🚀.

Code:
import turtle as t
t.getscreen()
tit = t.textinput("TITLE:", 'Enter the title:')
t.title(tit)
bg = t.textinput("BG COLOUR:", 'Enter the background colour:')
t.bgcolor(bg)
t.shape("classic")

figure_list = ["circle", "square", "rectangle", "triangle", "star", "heart","line"]

while True:
shape = t.textinput("SHAPE:", 'Enter the shape to be drawn (circle/square/rectangle/triangle/star/line/heart):')

if shape not in figure_list:
t.textinput("ERROR", f"'{shape}' not in available shapes.\nPress OK to try again.")
continue

pensize = t.textinput("PEN SIZE:", 'Enter the pen size:')
t.pensize(int(pensize))

pencolour = t.textinput("PEN COLOUR:", 'Enter the pen colour:')
t.pencolor(pencolour)

colour = t.textinput("FILL COLOUR", "Type a fill colour:")
x_axis = float(t.textinput("Location", "x = ?"))
y_axis = float(t.textinput("Location", "y = ?"))

confirm = t.textinput("SETUP READY:", 'Type Ok to continue:')
if confirm.lower() != "ok":
continue

t.penup()
t.goto(x_axis, y_axis)
t.pendown()
t.fillcolor(colour)
t.begin_fill()

if shape == "circle":
size = int(t.textinput("SHAPE SIZE", "Enter the radius:"))
t.circle(size)

elif shape == "square":
side = int(t.textinput("SHAPE SIZE", "Enter the side length:"))
for _ in range(4):
t.forward(side)
t.left(90)

elif shape == "rectangle":
width = int(t.textinput("SIZE", "Enter the short edge:"))
height = int(t.textinput("SIZE", "Enter the long edge:"))
for _ in range(2):
t.forward(width)
t.left(90)
t.forward(height)
t.left(90)

elif shape == "triangle":
side = int(t.textinput("SHAPE SIZE", "Enter the side length:"))
for _ in range(3):
t.forward(side)
t.left(120)

elif shape == "star":
size = int(t.textinput("SHAPE SIZE", "Enter the size:"))
for _ in range(5):
t.forward(size)
t.right(144)

elif shape == "heart":
size = int(t.textinput("SHAPE SIZE", "Enter the heart size:"))
t.left(50)
t.forward(size)
t.circle(size * 0.3, 200)
t.right(140)
t.circle(size * 0.3, 200)
t.forward(size)
t.setheading(0)

elif shape == "line":
length = int(t.textinput("SHAPE SIZE", "Enter the line length:"))
t.forward(length)

else:
pass

t.end_fill()

again = t.textinput("MORE SHAPES?", "Do you want to add more shapes? (yes/no):")
if again.lower() != "yes":
break

t.mainloop()