Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will write an improved version of the eight_parallelogram.py that you created for week 3. In this version, you will create the following two functions:

You will write an improved version of the eight_parallelogram.py that you created for week 3. In this version, you will create the following two functions: parallelogram(s, parallelogramColor): This function draws a single parallelogram with longest side of length s and color parallelogramColor, as described in the Week 3 Assignment. pinwheel(s, nroParallelograms, parallelogramColor): This function uses a for-loop to call the function parallelogram() in order to draw the pinwheel. The parameter s represents the long diagonal of the parallelogram, nroParallelograms indicates the number of parallelograms in the pinwheel, and parallelogramColor is the fill color of the parallelograms. Your program should draw three pinwheels, in three different sizes, colors and at different locations on the window. Create a function main() which asks the user for the sizes of the three pinwheels, the number of parallelograms in each pinwheel, and three color names. Take a screenshot of the output of your program and submit with your program files. Call the screenshot file pinwheel_redux.PNG

eight_parallelogram.py

import turtle import math

#Ask user for numerical value of lenght S = eval(input("Enter a numerical value"))

#calculate length of parallelogram length = S /math.cos(math.pi/4)/2

#starting point for parallelogram turtle.penup() turtle.goto(-150,length /2) turtle.pendown()

#Draw the first parallelogram turtle.begin_fill() turtle.color("pink") turtle.left(90) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.right(135) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.end_fill()

#second parallelogram turtle.begin_fill() turtle.color("red") turtle.right(180) turtle.left(90) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.right(135) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.end_fill()

#third parallelogram turtle.begin_fill() turtle.color("orange") turtle.right(180) turtle.left(90) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.right(135) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.end_fill()

#fourth parallelogram turtle.begin_fill() turtle.color("pink") turtle.right(180) turtle.left(90) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.right(135) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.end_fill()

#fifth parallelogram turtle.begin_fill() turtle.color("red") turtle.right(180) turtle.left(90) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.right(135) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.end_fill()

#Sixth parallelogram turtle.begin_fill() turtle.color("orange") turtle.right(180) turtle.left(90) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.right(135) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.end_fill()

#Seventh Parallelogram turtle.begin_fill() turtle.color("pink") turtle.right(180) turtle.left(90) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.right(135) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.end_fill()

#Eight parallelogram turtle.begin_fill() turtle.color("red") turtle.right(180) turtle.left(90) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.right(135) turtle.forward(length) turtle.right(45) turtle.forward(length) turtle.end_fill()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions