from collections import namedtuple
import random
import sys

W = 800
H = 600
RED = 200, 0, 0
BLUE = 0, 0, 200
GREEN = 0, 200, 0

ball = Rect((W/2, H/2), (30, 30))
Direction = namedtuple('Direction', 'x y')
ball_dir = Direction(5, -5)

bat = Rect((W/2, 0.96 * H), (150, 15))
N_BLOCKS = 8
BLOCK_W = W / N_BLOCKS
BLOCK_H = BLOCK_W / 4
BLOCK_COLOURS = RED, GREEN, BLUE

blocks = []
for n_block in range(N_BLOCKS):
    block = Rect((n_block * BLOCK_W, 0), (BLOCK_W, BLOCK_H))
    blocks.append((block, BLOCK_COLOURS[n_block % len(BLOCK_COLOURS)]))

def draw_blocks():
    for block, colour in blocks:
        print(block)
        screen.draw.filled_rect(block, colour)

def draw():
    screen.clear()
    screen.draw.filled_rect(ball, RED)
    screen.draw.filled_rect(bat, RED)
    draw_blocks()

def on_key_down():
    sys.exit()

def on_mouse_move(pos):
    x, y = pos
    bat.center = (x, bat.center[1])

def move(ball):
    """returns a new ball at a new position
    """
    global ball_dir
    ball.move_ip(ball_dir)

    if ball.x > W or ball.x <= 0:
        ball_dir = Direction(-1 * ball_dir.x, ball_dir.y)

    if ball.y <= 0:
        ball_dir = Direction(ball_dir.x, ball_dir.y * -1)

    if ball.colliderect(bat):
        ball_dir = Direction(ball_dir.x, - abs(ball_dir.y))


    if ball.y > H:
        sys.exit()



def update():
    move(ball)

@@ -363,68 +363,270 @@
 UE%0A%0A
-blocks = %5B%5D%0Afor n_block in range(N_BLOCKS):%0A    block = Rect
+%0Aclass Block(Rect):%0A    %0A    def __init__(self, colour, rect):%0A        Rect.__init__(self, rect)%0A        self.colour = colour%0A        %0Ablocks = %5B%5D%0Afor n_block in range(N_BLOCKS):%0A    colour = BLOCK_COLOURS%5Bn_block %25 len(BLOCK_COLOURS)%5D%0A    block = Block(colour, 
 ((n_
@@ -665,16 +665,17 @@
 LOCK_H))
+)
 %0A    blo
@@ -689,60 +689,13 @@
 end(
-(
 block
-, BLOCK_COLOURS%5Bn_block %25 len(BLOCK_COLOURS)%5D)
 )%0A%0Ad
@@ -725,24 +725,16 @@
 or block
-, colour
  in bloc
@@ -741,29 +741,8 @@
 ks:%0A
-        print(block)%0A
     
@@ -776,16 +776,22 @@
 (block, 
+block.
 colour)%0A

Make block a subclass of Rect