Write a program that will draw 7 shapes.

Your shapes should:

Start with 0 points
Each increase the number of points by 1 (ie: line- 2 points, triangle- 3 points, square- 4 points, etc.)
Start with a radius of 20 and increase in radius by 20 pixels each time
All be drawn from the same starting position
Initialize Tracy’s starting position using: setposition(0, -150)
Hint: It may be difficult to control both the radius of the shape and the number of points with the value of i. You may want to use a separate variable called radius to control the radius of the shape.

1 answer

Below is a Python program that uses the turtle graphics library to draw seven shapes. Each shape will have an increasing number of points and an increasing radius, starting from 20 pixels. The program will start drawing from the position (0, -150).

Make sure you have the turtle library installed and use Python environment to run the program.

import turtle

# Function to draw a shape with a specified number of points and radius
def draw_shape(points, radius):
    angle = 360 / points
    turtle.penup()
    turtle.setposition(0, -150)  # Starting position
    turtle.pendown()
    turtle.pencolor("black")
    turtle.fillcolor("lightblue")
    turtle.begin_fill()
    for _ in range(points):
        turtle.forward(radius)
        turtle.left(angle)
    turtle.end_fill()
    turtle.penup()
    turtle.right(angle)  # Reset orientation for the next shape
    turtle.forward(radius + 10)  # Move forward to avoid overwriting shapes

# Initialize turtle
turtle.speed(2)  # Set the drawing speed
turtle.pensize(2)  # Set the pen size

# Draw 7 shapes
for i in range(1, 8):  # Draw shapes from 1 to 7 points
    radius = 20 * i  # Increase radius by 20 pixels for each shape
    draw_shape(i, radius)  # Draw shape with `i` points and current radius

turtle.hideturtle()  # Hide the turtle cursor
turtle.done()  # Finish drawing

Explanation:

  1. Function draw_shape(points, radius): This function draws a shape based on the number of points and radius provided.

    • It calculates the angle for each corner of the shape using 360 / points.
    • The turtle moves forward by the length of the radius and turns by the calculated angle to create the shape.
  2. Main Loop:

    • The loop iterates from 1 to 7, representing the number of points for each shape.
    • The radius of each subsequent shape increases by 20 pixels.
  3. Turtle Setup: The drawing starts from the position (0, -150), and the drawing speed and pen size can be adjusted as needed.

Run the Code:

Make sure to run this code in an environment that supports turtle graphics, such as a local Python installation with a GUI, because turtle graphics may not function in some online interpreters.

Similar Questions
  1. Write a program that will draw 7 shapes.Your shapes should: Start with 0 points Each increase the number of points by 1 (ie:
    1. answers icon 1 answer
  2. Select the term or phrase that best completes each sentence.Organic shapes are ________________________. (1 point) Responses
    1. answers icon 1 answer
  3. Three shapes are shown below.image fc340dcde99f440f88d14e1e7275937e Select ALL the statements that are true. A. All three shapes
    1. answers icon 1 answer
  4. Three shapes are shown below.image fc340dcde99f440f88d14e1e7275937e Select ALL the statements that are true. A. All three shapes
    1. answers icon 2 answers
more similar questions