Question: ====================================================== This code draw octagons but i need to replace ocatgon with hexagon : ===================================================== The code: import turtle t = turtle.Turtle() angle = 45

======================================================

This code draw octagons but i need to replace ocatgon with hexagon :

=====================================================

The code:

import turtle t = turtle.Turtle() angle = 45 # octagons

#create octagons def drawHex(): t.pendown() t.right(angle) t.backward(50) t.right(angle) t.backward(50) t.right(angle) t.backward(50) t.right(angle) t.backward(50) t.right(angle) t.backward(50) t.right(angle) t.backward(50) t.right(angle) t.backward(50) t.right(angle) t.backward(50) t.penup() # draw the upper shapes for col, y in ('red', 0.0), ('blue', -25.0),('brown', -50.0): t.color(col) t.sety(y) drawHex() #draw circles t.color('black') t.fillcolor('black') t.setx(15.0) t.sety(35) t.pendown()

t.begin_fill() t.circle(3) t.end_fill()

t.penup() t.setx(30.0) t.pendown()

t.begin_fill() t.circle(3) t.end_fill()

t.penup() t.setx(0.0) t.sety(0.0)

#draw the bottom shapes for col, y in ('green', -150.0), ('yellow', -200.0): t.color(col) t.sety(y) drawHex()

But I need to replace octagons to hexagon:

====================================

I need the code to display these hexagons shape

====================================================== This code draw octagons but i need to replace ocatgon with

Question 2:(10 marks) Turtle Graphics is a Python feature like a drawing board, which lets us command a th to draw all over it! We can use functions like forward(...) and right(...) which can mov the turtle around. Commonly used turtle methods are found in the posted pdf file "tur - Turtle graphics - Python 3.7.1rc1 documentation" To make use of the turtle methods and functionalities, we need to import turtle. "turtle comes packed with the standard Python package and need not be installed externall The roadmap for executing a turtle program follows 3 steps: 1. Import the turtle module 2. Create a turtle to control. 3. Draw around using the turtle methods. Problem: In geometry, a hexagon is a six polygon. Each internal angle is 120 degrees (outer is 60). Based on what you have learned in this course and using the appropriate commands, you are asked to Design the algorithm and implement a python program that draws the diagram using the turtle. You should consider the following points in your solution: 1- Each hexagon side has a length of 50 units. 2- Each hexagon has a different color. 3- The final shape of the output should be as shown above. 4- You might place the desired colors in a list to access them by index in the drawing loop. 5- Make sure to set properly the starting position ( x&y ) of your drawing, to maintain the above diagram. 6- You need to draw two circles with fill color as shown in the figure

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!