Python hw
import turtle import math t = turtle.Turtle() t.shape("turtle") t.speed(0) t.width(8) def drawRectangle(width, height, tilt, penColor, fillColor): t.tilt t.color(penColor, fillColor) t.begin_fill() t.seth(tilt) t.forward(width) t.left(90) t.forward(height) t.left(90) t.forward(width) t.left(90) t.forward(height) t.end_fill() t.seth(0) def drawTriangle(base, height, penColor, fillColor): t.begin_fill() t.color(penColor, fillColor) t.forward(base) turnAngle = 180 - math.degrees(math.atan2(height,base/2)) t.left(turnAngle) side = math.sqrt((base/2)**2 +(height**2)) t.forward(side) t.left(2*(180-turnAngle)) t.forward(side) t.seth(0) t.end_fill() def drawRectangle2(width, height, tilt, penColor, fillColor): t.tilt t.color(penColor, fillColor) t.begin_fill() t.seth(tilt) t.forward(width) t.right(90) t.forward(height) t.right(90) t.forward(width) t.right(90) t.forward(height) t.end_fill() t.seth(0)