import pygame, sys
from pygame.locals import *
pygame.init()

width = 800
height = 600
DISPLAYSURF = pygame.display.set_mode((width, height))

clock = pygame.time.Clock()
posX = 400
posY = 10
dY = 5
radius = 10

while True:

    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

    # FILL IN ALL CODE HERE!!!
    posY += dY

    # Change direction if at the bottom.
    if posY > 590:
        dY = -dY

    # Change direction at the top.
    if posY < 10:
        dY = -dY


    DISPLAYSURF.fill(pygame.Color(0, 0, 0))
    pygame.draw.circle(DISPLAYSURF, pygame.Color("red"), (posX,posY), radius)
    pygame.display.update()
    clock.tick(50)
