Free Python Code for Creating a Rectangle

This is free Python 3x code to draw a rectangle in just a few lines of code. Just copy and paste the code into Python and run it:

from tkinter import *
canvas = Canvas(width=300, height=300, bg='white')
canvas.pack(expand=YES, fill=BOTH)

canvas.create_rectangle(20, 20, 300, 300, width=5, fill='red')

mainloop()