How to draw "square" dots instead of "round" dots with python 3 turtle?

  python-3.x, python-turtle

I have this script:

import turtle
from math import sqrt
def isPrime(n):
    if n < 2: return False
    if n == 2: return True
    if n % 2 == 0: return False
    k = 3
    while k < sqrt(n):
        if n % k == 0:
            return False
        k += 2
    return True

def plot(k):
    numPrimes = 0
    turtle.pu()
    turtle.speed(0)
    turtle.pencolor("green")
    turtle.dot(5)
    n= 1
    dir = 1
    for i in range(80):
        for j in range(n):
            turtle.setx(turtle.xcor() + 7*dir)
            if isPrime(k):
                numPrimes += 1
                turtle.pencolor("red")
            else:
                turtle.pencolor("black")
            turtle.dot(5)
            k += 1
        for j in range(n):
            turtle.sety(turtle.ycor() + 7*dir)
            if isPrime(k):
                turtle.pencolor("red")
                numPrimes += 1
            else:
                turtle.pencolor("black")
            turtle.dot(5)
            k += 1
        n += 1
        dir = -dir
    print(k-1, numPrimes)
    turtle.hideturtle()

plot(1)

It will draw rounded dots on the pane, but I want to draw "squared" dots (stamps?) that touch each other so there is no white space between the dots, and the dots themselves are not round, but square.

Basically it should look like a massive chessboard after, instead of a "pane with dots"

This is what it produces now
enter image description here

I want this enter image description here
(never mind the inaccuracy in this last screenshot of primes and non-prime, it is just to visualise what I mean by "square dots without white space"

How would I achieve this?
There seems to be no dot() in turtle that produces square stamps instead of round dots.

Source: Python-3x Questions

LEAVE A COMMENT