Question: Write a turtle program that asks the user for a numerical value S and draws four parallelogram prisms. Each prism is made of 2 parallelograms
Write a turtle program that asks the user for a numerical value S and draws four parallelogram prisms. Each prism is made of 2 parallelograms and a top square, forming the following shape, using at least four colors of your preference: The input value S represents the long side (hypotenuse) of each parallelogram
All sides are the same length, which is given by the expressions S2cos(?4)S2cos?(?4). The two internal narrow angles are of 45 degrees, and the two wider angles are of 135 degrees. NOTE: When using Turtle graphics, the angles we use in all turns (i.e., turtle.right and turtle.left) correspond to the outside angle of the turn. That is, if we draw the parallelogram starting at the bottom-left corner, drawing its bottom side first, we will be doing the following left turns (the turn angle we need is 180 minus the internal angle of the corner we want to recreate): After drawing the 1st parallelogram, the turtle will be heading in a South Westerly direction. At this point, doing a 180 degree right turn, will orient the turtle in the correct direction to go up and draw the top of the prism. To draw the next parallelogram you will need to relocate the turtle back to the lower left corner of the 1st parallelogram, as illustrated in the image below and then repeat the instructions you use to draw the 1st parallelogram: TIP: All parallelogram prisms are identical; they are just drawn in different orientations. So, copy-and-paste can come handy in replicating the actions needed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
