# [Tutor] Tile Code

niyanaxx95 at gmail.com niyanaxx95 at gmail.com
Fri Nov 14 02:20:14 CET 2014

```Statement:

1. The first and last tile in the first row shall be black.
2. The first and last tile in the first column shall be black.
3. The tiles will alternate between black and lemon

The task is to write a function to compute and print:
 the number of tiles needed in the first row (the number of columns)
 the number of tiles needed in the first column (the number of rows)
 the total number of tiles needed to cover the floor
 the gap at the end of each row
 the gap at the end of each column
And then print (using a function):
1. The colored tile pattern to a graphics window
a. The pattern should be printed centered in the graphics window, with equal gaps at
the end of each row, and equal gaps at the end of each column

Use functions to:
1. Read and validate the input values
a. Width
b. Length
c. Tile Size
2. Compute the number of rows, columns, total tiles required, and the size of the gaps at the
end of each row and column
3. Print the tile pattern

This is my outline but some things I do not  know how to do.

from graphics import GraphicsWindow

x = 10

y = 10

def main() :

--> // do stuff

--> width = getNumber("Choose a width: ", "Invalid value.", 1, 1000)

--> height = getNumber("Choose a height: ", "Invalid value.", 1, 1000)

--> win = GraphicsWindow(width, height)

--> canvas = win.canvas()

--> drawCheckerboard(canvas, x, y, width, height)....

main()

According to the constraints he wants you to use convenient functions. Those would likely be, getNumber() and drawCheckerboard()

You want a number between A and B so we have

# Prompt user with "msg" to return a number between "min" and "max" otherwise output "err_msg"

def getNumber(msg, err_msg, min, max):

--> num = min - 1

--> while num < min or num > max

--> --> num = input(msg)

--> --> if num < min or num > max

--> --> --> print(err_msg) // print invalid msg

# Draws checkerboard

def drawCheckerboard(canvas, x, y, width, height) :

--> // more stuff let me know when you get to this part

Sent from Windows Mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141114/655d0013/attachment-0001.html>
```