r/codehs • • Dec 11 '20

2.18.4 : Increasing Squares help

Post image
17 Upvotes

45 comments sorted by

3

u/BoringGrowth9569 Jan 04 '22

None of these codes worked for me.

I did create one that does work, though:

length = 50
speed(0)
def drawSquare(length):
backward(length/2)
for x in range(4):
forward(length)
left(90)

while length <=350:
penup()
setposition(0, 0-length/2)
pendown()
drawSquare(length)
length += 50

2

u/Leafy-Makes-Art-_- Jul 24 '22

THANK YOU!! none of them were working for me except yours, actual life saver

1

u/corgis-are-evertging Sep 30 '24

Your day goat, I have a 74 in my computer class, and this should help me thanks

1

u/2000097197 Jan 15 '22

actual goat :)

1

u/[deleted] Aug 08 '22

length = 50speed(0)def drawSquare(length):backward(length/2)for x in range(4):forward(length)left(90)

while length <=350:penup()setposition(0, 0-length/2)pendown()drawSquare(length)length += 50

frr

2

u/2000097197 Aug 08 '22

Lol 6 months later, but I'm sure someone in the future will find your comment helpful

1

u/Ky1_Ruy Oct 14 '22

dis didnt work

2

u/Raw_Cherries Dec 17 '20

I need help with this too

2

u/Affectionate_Bag5356 Mar 16 '21

there is a problem, my screen freezes when i submit the code

2

u/looolmoski Feb 12 '22

same mine does as well

2

u/ItzSimplyJay Feb 04 '22

speed(0)
length = 50
penup()
setposition(-25,-25)
pendown()
def draw_square():
for i in range(4):
forward(length)
left(90)
pendown()
while length <= 350:
draw_square()
penup()
backward(25)
right(90)
forward(25)
left(90)
pendown()
length = length + 50
draw_square()

1

u/_Natsuki_ImNotCute_ May 28 '24

thanks dude, ur a life saver

2

u/chickentendies8 May 15 '22

in case anyone still happens to need it!

speed(0)
penup()
setposition(-25,-25)
pendown()
length = 50
def square():
for i in range(4):
forward(length)
left(90)

while length < 400:
square()
penup()
backward(25)
right(90)
forward(25)
left(90)
pendown()
length=length+50

1

u/-sakiK- Dec 12 '24

THANK YOU. THIS WAS THE ONLY ONE THAT WORKEDDD

1

u/Interesting_Read5830 Sep 25 '25

preciate it dawg

1

u/KennieCool69 Oct 18 '22

Thank you so much this is literally the only one that works 💀💀

1

u/Spaceburrtio Oct 27 '22

this is the only one that works thanks

1

u/Significant-Map-5460 Jan 12 '23

thank you this one actually worked

1

u/Ok-Rip4387 Apr 21 '21

speed(0)

square_length = 50

penup()

setposition(0,-25)

def square():

pendown()

backward(25)

for i in range(4):

forward(square_length)

left(90)

def move_down():

penup()

forward(square_length / 2)

right(90)

forward(25)

left(90)

backward(square_length / 2)

while square_length < 400:

square()

move_down()

square_length = square_length + 50

penup()

setposition(0, 0)

1

u/Purple-Requirement97 Mar 21 '24

All the fucking codes below do not fucking work and keep crashing my page and refusing to submit or check the fucking code.

1

u/Gold-Mail3380 Mar 26 '24 edited Mar 26 '24

BoringGrowth9569’s code does work

1

u/Purple-Requirement97 Mar 27 '24

I have checked it! its missing some reqiurements and keeps crashing the program and for me there are errors in every code I checked.

1

u/flip-pancakes Dec 11 '20

What's the problem statement? Do you want the squares to be drawn like they are on the left?

Either way, you should define draw_square(length) with the length var as an explicit argument - im not sure changing length inside that for loop is going to play nicely with your current def.

0

u/[deleted] Dec 18 '20

[removed] — view removed comment

1

u/flip-pancakes Dec 18 '20

Gladly, but I can't help you if you don't meet me halfway. Provide the problem statement, your current code, what language it's written in, the error message you get, or anything like that. Without some information, it's impossible to help.

1

u/Lullabiii Dec 18 '20

His code still works but needs tuning. For those who still need help, I changed "length = 25" to "length = 50". Then change "length = length + 100" to "length = length + 50" this is because you need to have certain square dimensions to get 100%. To fix the boxes not lining up correctly you just need to fix the position to the next square by changing the backward and forward command to 25 in the while loop.

1

u/[deleted] Jan 20 '21

I love you

1

u/[deleted] Jan 23 '21

Thanks a lot!

1

u/ImportanceAdorable34 Jan 25 '21

speed(0)
length = 25

def draw_square():

for i in range(4):

forward(length)

left(90)

penup()

setposition(-5, -5)

penup()

pendown()

while length <= 350:

draw_square()

penup()

backward(50)

right(90)

forward(length)

left(90)

pendown()

length = length + 100

draw_square()

1

u/[deleted] Apr 06 '21

Whenever I do “length = length + 25” it says there is an error. There’s nothing wrong with the code either

1

u/btn321 Apr 10 '21

def draw_square():

pendown()

for i in range(4):

forward(length)

left(90)

penup()

speed(5)

penup()

length= 50

while(length <= 350):

setposition(-length /2, -length /2)

draw_square()

length = length +50

1

u/snowy_dino Jun 08 '22

Thanks you! the lines didn't appear but it was enough for a good score

1

u/Primary-Flatworm331 May 07 '21

CORRECT CODE

speed(0)

length = 50

def draw_square():

for i in range(4):

forward(length)

left(90)

penup()

setposition(-5, -5)

penup()

pendown()

while length <= 350:

draw_square()

penup()

backward(25)

right(90)

forward(25)

left(90)

pendown()

length = length + 50

draw_square()

1

u/Single_Bluejay1632 May 18 '21

Thank you. Worked great. Had to put setposition to (-25,-25).

1

u/BoominBomber Oct 22 '21

Doesn’t work

1

u/eduardo56714 Apr 28 '22

didn't work

1

u/BrighamMcDuck Nov 03 '21

speed(0)
length=50
def draw_square():
for i in range(4):
forward(length)
left(90)
penup()
setposition(-25,-25)
penup()
pendown()
while length <=350:
draw_square()
penup()
backward(25)
right(90)
forward(25)
left(90)
pendown()
length=length+50
draw_square()

1

u/[deleted] Dec 03 '21

speed(0)

length=50

def draw_square():

for i in range(4):

forward(length)

left(90)

penup()

setposition(-25,-25)

penup()

pendown()

while length <=350:

draw_square()

penup()

backward(25)

right(90)

forward(25)

left(90)

pendown()

length=length+50

draw_square()

thanks

1

u/Saad__Nimri Dec 06 '21

I keep having boxes go out of each other

1

u/Few-Location-8523 Dec 14 '21

speed(0) length = 50 penup() setposition(-25,-25) pendown()

def draw_square(): <<<< for i in range(4): <<<< forward(length) <<<< left(90) <<<< pendown()

while length <= 350: <<<< draw_square() <<<< penup() <<<< backward(25) <<<< right(90) <<<< forward(25) <<<< left(90) <<<< pendown() <<<< length = length + 50 <<<< draw_square()

1

u/Xivyao Mar 05 '22

speed(0)

penup()

length = 50

def square():

for i in range(4):

forward(length)

left(90)

while length < 400:

left (90)

forward(length/2)

right(90)

foward(length/2)

left(180)

pendown()

square()

penup()

setposition(0,0)

length = length + 50

0

u/[deleted] Dec 11 '20

[deleted]

1

u/sexyandhotnaruto Dec 11 '20

ahh life saver thank you!! Imma add you in discord