You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

# 2.11.5 Line of Increasing Blocks CodeHS Answers

We thoroughly check each answer to a question to provide you with the most correct answers. Found a mistake? Tell us about it through the REPORT button at the bottom of the page. Ctrl+F (Cmd+F) will help you a lot when searching through such a large set of questions.

The most common answers is:

``````speed(0)
penup()
setposition (-150,0)
It’s being difficult!!!!!!!!!!!!!!!!!!! But it’s functional at least
def square():
length = 10
for i in range(4):
length = 10
forward(length)
right(90)
def square2():
length = 20
for i in range(4):
length = 20
forward(length)
right(90)
def square3():
length = 30
for i in range(4):
length = 30
forward(length)
right(90)
def square4():
length = 40
for i in range(4):
length = 40
forward(length)
right(90)
def square5():
length = 50
for i in range(4):
length = 50
forward(length)
right(90)
pendown()
square()
penup()
forward(20)
pendown()
square2()
penup()
forward(30)
pendown()
square3()
penup()
forward(40)
pendown()
square4()
penup()
forward(50)
pendown()
square5()``````

This code is functional but can be significantly optimized to reduce repetition and improve readability. Here’s a revised version that accomplishes the same task more efficiently:

``````import turtle

turtle.speed(0)
turtle.penup()
turtle.setposition(-150, 0)

def draw_square(length):
for _ in range(4):
turtle.forward(length)
turtle.right(90)

for i in range(1, 6):
turtle.pendown()
draw_square(10 * i)  # Draw square of increasing size
turtle.penup()
turtle.forward(15 * i)  # Move forward to start position for next square

turtle.done()
``````

This optimized version introduces a single function, draw_square(length), which draws a square of a given side length. The for loop then iterates through a range, drawing increasing-sized squares based on the loop counter.

The moving forward distance is also adjusted to ensure that the squares do not overlap, considering their increasing size.

This approach greatly simplifies the code by eliminating the need for multiple, nearly identical functions for drawing squares of different sizes.

#### Quizzma Team

The Quizzma Team is a collective of experienced educators, subject matter experts, and content developers dedicated to providing accurate and high-quality educational resources. With a diverse range of expertise across various subjects, the team collaboratively reviews, creates, and publishes content to aid in learning and self-assessment.
Each piece of content undergoes a rigorous review process to ensure accuracy, relevance, and clarity. The Quizzma Team is committed to fostering a conducive learning environment for individuals and continually strives to provide reliable and valuable educational resources on a wide array of topics. Through collaborative effort and a shared passion for education, the Quizzma Team aims to contribute positively to the broader learning community.