0

I want to draw a checkerboard on Python, but I only get one black square.
Can you help me fix this program?

import turtle

def filled_square(size, color, x, y):
    turtle.setpos(x, y)
    turtle.color(color)
    turtle.begin_fill()
    for i in range(4):
        angle = 90
        turtle.fd(size)
        turtle.lt(angle)
    turtle.end_fill()
    turtle.up()

import sys
n = int(sys.argv[1])
s = int(sys.argv[2])

square_size = s//n
y=0

for i in range(n):
    x = 0
    for j in range(n):
        if (i+j)%2==0:
            filled_square(square_size, "red", x, y)
        else:
            filled_square(square_size, "black", x, y)
    x+=square_size
    turtle.down()

turtle.done()

Edited by Loulou_1

3
Contributors
2
Replies
24
Views
2 Months
Discussion Span
Last Post by happygeek
0

please could you help this question

pythan ask for name and exam score(1-100) of a student and tell if student failed (scored less than 40)

ask for number of steps walked in aday and tell how many steps you need to walk more to be healthy . A healthy person should walk 10,000 steps.

ask for price of two items you are buying from Amazon and tell if it qualifies for free shipping if yu buy for items more than $30, you qualify for free shipping.

1

@Abdikadir

Firstly, it's not good form to hijack someone else's question to ask your own unrelated one (or even a related one for that matter)

Secondly, it's even worse form and against the rules here at DaniWeb to post a homework assignment and expect people to just do your work for you. The rules state: 'provide evidence of having done some work yourself if posting questions from school or work assignments'

So here's your answer: start a new thread to ask your question, and in it show us your code (or pseudo-code) and explain exactly where you are getting stuck and what help you are looking for.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.