Draw and erase shapes in Python with Turtle: Beginner Coding Tutorial
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()
Видео Draw and erase shapes in Python with Turtle: Beginner Coding Tutorial канала Rivan
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()
Видео Draw and erase shapes in Python with Turtle: Beginner Coding Tutorial канала Rivan
Комментарии отсутствуют
Информация о видео
2 июля 2025 г. 5:25:14
00:00:26
Другие видео канала