The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display.



The pinstripes should either follow the system palette sequence,   or a sequence that includes:

black,   red,   green,   blue,   magenta,   cyan,   yellow,   and   white:

   after filling the top quarter, switch to a wider 2 pixel wide vertical pinstripe pattern,
   halfway down the display, switch to 3 pixel wide vertical pinstripe,
   finally to a 4 pixels wide vertical pinstripe for the last quarter of the display.


See also

   display black and white 
   print colour


 
from turtle import *
 
colors = ["black", "red", "green", "blue", "magenta", "cyan", "yellow", "white"]
 
# Middle of screen is 0,0
 
screen = getscreen()
 
left_edge = -screen.window_width()//2
 
right_edge = screen.window_width()//2
 
quarter_height = screen.window_height()//4
 
half_height = quarter_height * 2
 
speed("fastest")
 
for quarter in range(4):
    pensize(quarter+1)
    colornum = 0
 
    min_y = half_height - ((quarter + 1) * quarter_height)
    max_y = half_height - ((quarter) * quarter_height)
 
    for x in range(left_edge,right_edge,quarter+1):
        penup()
        pencolor(colors[colornum])
        colornum = (colornum + 1) % len(colors)
        setposition(x,min_y)
        pendown()
        setposition(x,max_y)
 
notused = input("Hit enter to continue: ")
 