Draw a rectangle given its horizontal length (h) and vertical length (v). If the horizontal and vertical lengths are equal, a square is drawn. The rectangle is centered at (0, 0). The screen is set up to fit the proportion of the 320 x 220 screen. The vertical axis ranges from y = -44 to y = 44 while the horizontal axis ranges from x = -64 to x = 64.
from math import * from matplotlib.pyplot import * print("Draw a rectangle\nusing pyplot") h=eval(input("horiz. length? ")) v=eval(input("vert. length? ")) # set axis axis((-64,64,-44,44)) # set points xl=[-h/2,h/2,h/2,-h/2,-h/2] yl=[v/2,v/2,-v/2,-v/2,v/2] # color c='green' # draw rectangle plot(xl,yl,c) show()