Skip to content
Advertisement

wondering what happened to my python code that draw a checkerboard with turtle? any helps?

JavaScript

Current image: Image drawn by code

Intended image: Intended effect

My code won’t draw a correct checkerboard pattern, but I wonder why every for loop my square black and white both executed at the same time? I am not asking for the correct code that will get me the correct checkerboard and I just want an explanation for the mistakes in my code.

Advertisement

Answer

I don’t know how to explain your mistakes without giving you the correct code, but I will try:

basically the mistake is that black_square and white_square are drawing squares at the same location. The starting point is 50 units apart, but because the squares are drawn in opposite directions (clockwise and counter-clockwise), the resulting area overlaps. black_square would draw a square below the starting point, while white_square would draw a square above its starting point.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement