inside inside inside inside

Level 2
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
from turtle import*
def turtle_square():
    for i in range(4):
        left(90)
        forward(100)
def turtle_equilateral_triangle():
    for i in range(6):
        left(60)
        forward(100)
def turtle_hexagon():
    for i in range(3):
        left(120)
        forward(100)
def turtle_pentagon():
    for i in range(5):
        left(72)
        forward(100)
turtle_square()
turtle_equilateral_triangle()
turtle_hexagon()
turtle_pentagon()
turtle_equilateral_triangle()

which line can be commented out for the program to still run normally? Note that this makes a triangle inside a square inside a pentagon inside a hexagon.

second last line middle line last line first line

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

I've never been to coding, my guess is the last five lines are doing the job of accumulation, and the last line about the equilateral triangle simply appears twice. Love to know what's really the case.

I actually created this question when I was testing some stuff, and I was really confused why the equilateral triangle was creating a hexagon. This is actually a darn old program, and the first mistake was using "import turtle (which doesn't make any sense)" instead of "from turtle import*". There are so many lines due to the fact that I had to define everything. Could've been worse. The last five lines, five lines , did everything. But the main part is probably doing all the def this def that.

Odin Wang - 9 months, 2 weeks ago
Odin Wang
Aug 13, 2020

commenting out the last line actually does it. Note that the hexagon code makes an equilateral triangle and the equilateral triangle code makes a hexagon.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
from turtle import*
def turtle_square():
    for i in range(4):
        left(90)
        forward(100)
def turtle_equilateral_triangle():
    for i in range(6):
        left(60)
        forward(100)
def turtle_hexagon():
    for i in range(3):
        left(120)
        forward(100)
def turtle_pentagon():
    for i in range(5):
        left(72)
        forward(100)
turtle_square()
turtle_equilateral_triangle()
turtle_hexagon()
turtle_pentagon()
#turtle_equilateral_triangle()

it still works

Odin Wang - 10 months ago

I know why now tho

Odin Wang - 10 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...