3. Challenges 1¶
Each of these can be done in 4 lines of code, and one is import turtle
.
Do these challenges in the Python IDLE editor. You will first have to do sheet Writing your own programs using IDLE
In only 4 lines of code (each). Only the 1st need be 4 lines, the others can be 3 lines, as you only have to do import turtle
once.
If for each shape we end up where we start, and facing the same way. Then how many times do we turn? What is that in degrees? So for a square we do that in 4 chunks. That is360/4
. What would it be for a triangle, for a hexagon …
- Draw a square
- Draw a triangle
- Draw a hexagon
- Draw a 20 gon (that is a 20 sided shape).
What would happen if instead of turning 360°, we turned 2×360°? (in python that is2*360
).
Try some shapes with 5,7,8,9 … sides where the turtle turns 2×360°, or 3×360° or …
How do you need to change 360/n
where n
is the number of sides.