Python hw
import basicShapes from basicShapes import t import random import math t.speed(0) def drawTree(height, color): startx = t.xcor() starty = t.ycor() width = (1 / 2)*(height) topLeftX = startx topLeftY = starty + height topRightX = startx + width topRightY = starty + height bottomRightX = startx + width bottomRightY = starty shadesOfGreen =["#006400", "#556b2f", "#8fbc8f", "#2e8b57", "#3cb371", "#20b2aa", "#32cd32"] color = random.choice(shadesOfGreen) t.up() t.goto(startx, starty + (2/3)*height) t.down() basicShapes.drawTriangle(width, height/3, '', color) t.goto(startx, starty + (1/2)*height) basicShapes.drawTriangle(width, height/3, '', color) t.goto(startx, starty + (1/3)*height) basicShapes.drawTriangle(width, height/3, '', color) t.goto(startx+(2/5)*width, starty) basicShapes.drawRectangle(width/5, height/3, 0, '', 'brown') def drawForest(n): starty = t.ycor() shadesOfGreen =["#006400", "#556b2f", "#8fbc8f", "#2e8b57", "#3cb371", "#20b2aa", "#32cd32"] t.up() t.goto(-300,0) for i in range(n): t.up() t.seth(0) space = 25 + random.randint(-1, 1) t.forward(space) t.down() color = random.choice(shadesOfGreen) drawTree(random.randint(80,200), color) def drawHut(): startx = t.xcor() starty = t.ycor() topLeftX = startx topLeftY = starty + 100 middlex = startx + (100 / 2) rightLeftX = startx + 100 topLeftY = starty + 100 middley = starty + 100 t.pensize(3) for i in range(11): t.up() movego = random.randint(4,7) t.forward(movego) t.down() basicShapes.drawRectangle(random.randint(5, 15), 70, 0, "black", "brown") for i in range(12): t.up() t.goto(middlex -20,middley) t.down() basicShapes.drawRectangle2(random.randint(5, 15), random.randint(60, 70), 25 + random.randint(-90,40), "black", "brown") def drawHut(): for i in range(10): basicShapes.drawRectangle2(random.randint(8,12),random.randint(50,60),0,'black','red') def drawVillage(): for i in range(5): t.up() space = 200 + random.randint(-1,1) t.forward(space) t.down() drawHut() t.up() t.goto(-300,-300) t.down() if __name__=="__main__": print('Inside main of project01.py') # drawForest(14) drawVillage()