Draw and erase shapes in Python with Turtle: Beginner Coding Tutorial

Published: 01 July 2025
on channel: Rivan
26
3

This is the code to draw and Clear a red square using buttons in Python.

import turtle
t = turtle.Pen()
def redsq50():
turtle.color(1,0,0)
turtle.begin_fill()
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.end_fill()


from tkinter import *
tk = Tk()
btn = Button(tk, text = "red square", command=redsq50)
btn.pack()
def clearscreen():
turtle.clear()
turtle.reset()


btn = Button(tk, text = "Clear all", command=clearscreen)
btn.pack()


On this page of the site you can watch the video online Draw and erase shapes in Python with Turtle: Beginner Coding Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Rivan 01 July 2025, share the link with friends and acquaintances, this video has already been watched 26 times on youtube and it was liked by 3 viewers. Enjoy your viewing!