Write a python program that will allow a user to draw byinputting commands. The program will load all of the commands first(until it reaches command \"exit\" or \"done\"), and then create thedrawing.
Must include the following:
change attributes:
drawing:
draw_axes
draw_tri [x1] [y1] [x2] [y2] [x3] [y3
draw_rect [x] [y] [b] [h]
draw_poly [x] [y] [n] [s]
draw_path [path]
random
Heres my starter code:
import turtle
#================ command loading=================
lines = [] #initialize empty list
# load up all commands into the list
def load_commands():
 Â
while(1):
 Â
line = input('>')
 Â
words = line.split()
if words[0] == 'exit':
break
 Â
lines.append(line)
#============== turtle drawing functions============
def draw_rect(alex, x, y, b, h):
alex.pu()
alex.goto(x,y)
alex.pd()
 Â
for i in range(2):
alex.fd(b)
alex.lt(90)
alex.fd(h)
alex.lt(90)
 Â
#==================== process commands (do thedrawing)======
def process_commands():
 Â
# ------ initialize turtle stuff ----------------
 Â
turtle.TurtleScreen._RUNNING=True
 Â
wn = turtle.Screen() # Set up the window and its attributes
wn.bgcolor(\"lightgreen\")
wn.title(\"Alex meets a function\")
 Â
alex = turtle.Turtle() # Create alex
 Â
#-----------------------------------------
 Â
# process each line and draw
for line in lines:
 Â
words = line.split()
 Â
if words[0] == \"draw_rect\":
x = int(words[1])
y = int(words[2])
b = int(words[3])
h = int(words[4])
draw_rect(alex,x,y,b,h)
 Â
 Â
wn.exitonclick()
 Â
#================== MAIN ======================
 Â
def main():
print(\"loading commands\")
load_commands()
print(\"drawing\")
process_commands()
 Â
main()