Question

Write a program called draw_shapes.py. In your program, Create a block header with: your name the...

Write a program called draw_shapes.py.

In your program,

  1. Create a block header with:
    • your name
    • the date
    • a short description of what the program does:
      Assignment 5: Draw shapes using turtle
  2. Import the turtle module.
  3. Create a window and screen (canvas) where your turtle will draw. Make the window 400 pixels wide x 400 pixels high and give it an indigo background and a title of "Shapes". Use this code to create a window object:
    # a place for the turtle to draw
    win = turtle.Screen() # create a window object
  4. Create a turtle object and give it a name.
  5. Draw the following shapes. You may use 'for' loops or repetitive code depending on your comfort level with 'for' loops. Do not draw a line from one shape to the next Hint: penup(), goto(), and pendown()
    • A yellow-filled hexagon (six sides) starting at location (80,80) that has sides of length 40 pixels. Hints:
      • for i in range(6):
      • For a 6 sided object with equal sides turn 360/6 = 60 degrees at the end of each side before drawing the next side
    • A light green filled octagon (eight sides) starting at location (-20,20) that has sides of length 30. An octagon has 8 sides. Hints:
      • for i in range(8):
      • Turn 360/8 = 45 degrees at the end of each side
    • A pink filled triangle (three sides) starting at location (80, -120) that has sides of length 70. Hints:
      • for i in range(3):
      • Turn 360/3 = 120 degrees at the end of each side
  1. Add a statement to exit your program on a mouse click.

Save and run your program.

It should look like this:

Turtle window containing shapes: hexagon, octagon, and triangle.

Upload only your draw_shapes.py to this assignment. A screenshot is not necessary.

After instruction number 3 IDK what to type. After that, I get confused about what order should I put code in and I'm new using Py. Please help me out with this difficult Homework. thanks in advance.


i want this in detailed pls
0 0
Add a comment Improve this question Transcribed image text
Answer #1
draw_shapes.py

"""
Your Name: First Name Last Name
Date: YYYY-MM-DD
This program creates a turtle window of size 400 * 400
It draws a hexagon of side length 40 and octagon of side length 30 and a triangle of side length 70
"""
# import turtle module and set the screen size as 400 * 400 and fill background color as indigo
import turtle
win = turtle.Screen()
win.screensize(400, 400)
win.bgcolor('#4b0082')
win.title('Shapes')
tom = turtle.Turtle()
# the below code is to draw hexagon
# for loop iterates through 0-5 and it is filled with yellow color
tom.penup()
tom.goto(80, 80)
tom.pendown()
tom.fillcolor('yellow')
tom.begin_fill()
for i in range(6):
    # it moves 40 pixels to forward and makes an angle of 60 degrees to its right
    tom.forward(40)
    tom.right(60)
tom.end_fill()
# the below code is to draw octagon
# for loop iterates through 0-7 and it is filled with red color
tom.penup()
tom.goto(-20, 20)
tom.pendown()
tom.fillcolor('red')
tom.begin_fill()
for i in range(8):
    # it moves 30 pixels to forward and makes an angle of 45 degrees to its right
    tom.forward(30)
    tom.right(45)
tom.end_fill()
# the below code is to draw triangle
# for loop iterates through 0-2 and it is filled with pink color
tom.penup()
tom.goto(80, -120)
tom.pendown()
tom.right(60)
tom.fillcolor('pink')
tom.begin_fill()
for i in range(3):
    # it moves 70 pixels to forward and makes an angle of 120 degrees to its right
    tom.forward(70)
    tom.right(120)
tom.end_fill()
win.exitonclick()

- Lemain.py A L -IHL.PYA Your Name: First Name Last Name Date: YYYY-MM-DD This program creates a turtle window of size 400 *Shapes
Add a comment
Know the answer?
Add Answer to:
Write a program called draw_shapes.py. In your program, Create a block header with: your name the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Question Task 4 Create a function named poker_table that uses Turtle Graphics to create a...

    Python Question Task 4 Create a function named poker_table that uses Turtle Graphics to create a single poker table to accommodate all players. There should be four parameters: num_players indicates the number of players; side_length indicates the length in pixels of each side of the table; and x and y, which give the location where you should start drawing the table. The poker table should be a simple regular polygon (that is, with sides of equal length). The number of...

  • Turtle Graphics with nested loop: Write a turtle graphics python program repeat_squares.py that uses nested loops...

    Turtle Graphics with nested loop: Write a turtle graphics python program repeat_squares.py that uses nested loops to draw 100 squares, to create this design: Turtle-squares.png starting with the smallest square in the bottom right-hand corner. Start at position (-4,4). At each step increase the length of each side by 4 pixels. Draw 100 squares. Please submit with an animation speed of 0 and the turtle hidden turtle.hideturtle()

  • Java Turtles Drawing A Regular Polygon Write the code to have the turtle draw a regular...

    Java Turtles Drawing A Regular Polygon Write the code to have the turtle draw a regular polygon with the specified number of sides and specified side length. Draw the Specified number of regular polygons, each starting at the same place, however, after each polygon is drawn the turtle turns 360 / numpolys degrees

  • Writing the code in IDLE. Make sure the code is working. thank you so much Create the following turtle pattern. Using the turtle and random modules, write a program that creates an output as...

    Writing the code in IDLE. Make sure the code is working. thank you so much Create the following turtle pattern. Using the turtle and random modules, write a program that creates an output as the one shown in the picture below. Consider the following: . Change the color of the window to "red" using wn.bgcolor property of the screen variable you create. . Your turtle variable has to have a pen color "white", you have to use the .pencolor property...

  • Write a class named Octagon (Octagon.java) that extends the following abstract GeometricObject class and implements the...

    Write a class named Octagon (Octagon.java) that extends the following abstract GeometricObject class and implements the Comparable and Cloneable interfaces. //GeometricObject.java: The abstract GeometricObject class public abstract class GeometricObject { private String color = "white"; private boolean filled; private java.util.Date dateCreated; /** Construct a default geometric object */ protected GeometricObject() { dateCreated = new java.util.Date(); } /** Construct a geometric object with color and filled value */ protected GeometricObject(String color, boolean filled) { dateCreated = new java.util.Date(); this.color = color;...

  • GUI bouncing shapes program use this interface the out put of the program should be a jFr...

    GUI bouncing shapes program use this interface the out put of the program should be a jFrame with three buttons: “add triangle”, “add square” and “add circle” and a blank screen. when the user clicks any of these buttons the corresponding shape appears and starts bouncing around the screen. the shape of these shaoes and randomized and anytime the user clicks the button you should be able to keeping adding shapes on the screen while the previosus shape is bouncing...

  • create anything in python. Make sure your code covers all of the following things: • Use...

    create anything in python. Make sure your code covers all of the following things: • Use the concepts of object-based programming—classes, objects, and methods • Draw two-dimensional shape • Use the RGB system to create colors in graphics applications and modify pixels in images • Develop recursive algorithms to draw recursive shapes • Write a nested loop to process a two-dimensional grid • Perform simple transformations of images, such as conversion of color to gray-scale

  • For this lab you will write a small program that prints a few "shapes" using asterisks....

    For this lab you will write a small program that prints a few "shapes" using asterisks. Your program will prompt the user to select a shape by entering a number (square or triangle for B grade, add the zig- zag for the A grade). It will then prompt for the size, and then if a square or triangle is selected it will prompt for "not filled" or "filled", and if azig-zag is selected it will prompt for the number of...

  • Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu:...

    Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu: Enter Circle Enter Rectangle Remove Shape Draw Shapes Exit Circles – User inputs position, radius, and color. The position is the CENTER of the circle Rectangles – User inputs position, height, width, color. The position is the lower left-hand corner Colors – Allow red, yellow, blue, and green only Remove – Show the number of items in the list and let the user enter...

  • Linear Interpolation Write a program that will create a linear interpolation between two pixels. ...

    How to write this code in python? Linear Interpolation Write a program that will create a linear interpolation between two pixels. You are to read in two pixel values and generate a number of pixels specified between them. Input for the program 1 Enter the first pixel value: 0x002222 2 Enter the second pixel values: OxFFDD3:3 3 Enter the number of pixels to generate inbetween: 3 Using the 2 pixels specified it will generate 3 new pixels between the first...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT