Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python: Modify this program of spiral square so that it draws a hexagon (six-sid

ID: 3679970 • Letter: P

Question

Python:

Modify this program of spiral square so that it draws a hexagon (six-sided polygon) as in the picture

from turtle import *
import turtle
screen=Screen()
#getting width and height
width = screen.screensize()[0]
height= screen.screensize()[1]

#reading inputs
initialLength = int(input("length of initial line: "))
decr = int(input("Amount of decrement between each lines to draw: "))

#checking inputs for width and height
if(initialLength < width and initialLength<height):
turn = 90
start = height-3;
Draw = turtle.Turtle()
# filling sppiral square lines
while start < height:
Draw.forward(start) #drawing lines
Draw.right (turn)
start -= decr #decrementing every time
done()
else:
#if inputs are wrong
print('Inputs greater than screen width and height')

The program should still promot the user for the following inputs:

- The length of the initial (or first) line to draw

- The amount of decrement between each two lines to draw

Explanation / Answer

import turtle

myscreen=turtle.Screen();

width = myscreen.screensize()[0]
height= myscreen.screensize()[1]

initialLength = int(input("length of initial line: "))
decr = int(input("Amount of decrement between each lines to draw: "))

myTutrle= turtle.Turtle();

if(initialLength>0)

{

turn = 120

start = height-3;

}

while start < height:
myTurtle.forward(initialLength) #drawing lines
myTurtle.right (turn)
start -= decr #decrementing every time
done()
else:
#if inputs are wrong
print('Inputs greater than screen width and height')