Write the commands to draw a hexagon with each side equal to 40 turtle steps
Answers
Answer:
lt 45,fd 5o,rt 45,fd 50,rt 45 fd 50,rt 90,fd 50,rt 45,fd 50,rt 45,fd 50
Explanation:
Answer: - The commands to draw a hexagon with each side equal to 40 turtle steps are Turtle.forward(40) and Turtle.left(300).
The Program to draw a hexagon having each side equal to 40 turtle: -
# import the turtle modules
import turtle
# Start a work Screen
ws = turtle.Screen()
# Define a Turtle Instance
geekyTurtle = turtle.Turtle()
# executing loop 6 times for 6 sides
for i in range(6):
# Move forward by 40 units
geekyTurtle.forward(40)
# Turn left the turtle by 300 degrees
geekyTurtle.left(300)
Explanation: -
- You need to define an instance for the turtle, and then you need to execute 6 times the loop for the hexagon as it has 6 sides.
- Then, you need to put the length of the sides in every iteration as 40 units to move the turtle forward.
- And you need to move the turtle 300 degrees to the left.
- These steps will make the hexagon.
OR
- You can first import the turtle module.
- Then, you need to create a work screen using the turtle.Screen() method.
- Then you need to define the instance of the turtle using a turtle.Turtle() class.
- Then the same steps as mentioned in the above method.
So,
We used forward () and left () methods to make a hexagon.
The program: -
import turtle
screen=turtle.Screen()
TurtleIns=turtle.Turtle()
#iterate loop 6 times for 6 sides
for i in range(6):
TurtleIns.forward(40)
TurtleIns.left(300)
To know more about the topic, visit the below links: -
https://brainly.in/question/2444724
https://brainly.in/question/20852077
#SPJ3