[Tutor] Help

Prasad, Ramit ramit.prasad at jpmorgan.com
Fri Sep 21 00:54:59 CEST 2012

People on this list are not all receiving this via email. It is
recommended that you post 1. plain text (instead of Rich Text or HTML)
2. Just include the code directly in the email if it is short (which this 
is) or post to a website like pastebin for large samples. I have included 
the code below for the benefit of readers that do not receive attachments.

Brett Dailey wrote:
> I'm having trouble with a small project. Here's what it needs to do:
> Has variables for window width and window height and creates a window of that
> size.
> Has variables which control the number of columns and number of rows.
> From this, create a checkboard pattern which evenly fills the window. On
> approximately 10% of the squares (chosen at random) draw an image which is
> sized to just fit inside a checkboard square (use the smallest dimension).
> Keep the program open for 3 seconds and then quit.
> I've attached the code I have so far.
> "Pic" is just a place holder for an actual image.
> Not sure what to do with the while statements that are empty in the code.
> Thanks for the help,
> Brett

# Lab 3: Game Board
import pygame
import time


WinH = 600
WinW = 800
num_rows = 8
num_cols = 12

screen = pygame.display.set_mode((WinW,WinH))


markSurf = pygame.image.load("#Pic")
color = (0,0,0)
cell_width = WinW/num_cols
cell_height = WinH/num_rows

while #...
    while #...
    pygame.draw.rect(screen, color, (cell_width,cell_height), 0)
    if color == (0,0,0):
        color = (0,255,0)
        color = (0,0,0)

curRow = 0
while curRow < #....:
    if curRow %2 = 0:
        color = (0,0,0)
        color = (0,255,0)
    curRow +=1


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

More information about the Tutor mailing list