The techniques we used to create recursive triangles can be used with other figures as well. Create nested and corner versions of squares and of pentagons.
Note: All this question requires in an answer is to change the number of sides and angles.
Squares:
```
def nestedSquare(t,size):
if size < 10:
return
for sides in range (4):
nestedSquare (t,size/2)
forward(t,size)
turn(t,90)
def cornerSquare(t,size):
if size < 10:
return
for sides in range (4):
forward(t,size)
cornerSquare (t,size/2)
turn(t,90)
```
Nested Output (size 100):
Corners Output (size 100):
Pentagons:
```
def nestedPentagon(t,size):
if size < 10:
return
for sides in range (5):
nestedPentagon(t,size/2)
forward(t,size)
You might also like to view...
Which of the following import statements is required to use the Character wrapper class?
a. import java.String; b. import java.lang.Char; c. import java.Char; d. No import statement is required
The COUNTIF function counts the number of cells within a range that meet the criteria entered
Indicate whether the statement is true or false
Describe in detail the six project plan phases.
What will be an ideal response?
Ergonomic devices can match patterns stored in a database with a person’s iris, retina, voice, fingerprint, or handprint. _____________________
Answer the following statement true (T) or false (F)