15-110 Fall 2010 Quiz 4
10 Minutes

* No calculators, no notes, no books, no computers.
* Show your work.
  Correct answers without supporting calculations will not receive full credit.
* If you cannot solve a problem entirely, do what you can.  Include some code for partial credit.

1.       (50 pts)
Note:  For this question, you may use “for” loops, but you may not use “while” loops or recursion.
Write a function hasConsecutive  that takes a string and returns True if any character in the string occurs consecutively and False otherwise.  So your function should return True for “abccba” (because of “cc”), but it should return False for “abcabc”.


2.       (50 pts) Write a Tkinter graphics function drawCircles that takes these values:
     drawCircles(canvas, width, height)
This function takes a canvas along with its width and height, and draws a row of adjacent circles, each of radius 15, vertically centered in the canvas.  Draw as many circles as can fit entirely within the given width, but no more.  For example, if the canvas is 200x100, then this call:
     drawCircles(canvas, 200, 100)
creates this drawing:
quiz4-circles
Notice that there are 6 circles because a 7th circle would end at x=210, which is wider than the canvas.

3.       Bonus/Optional (5 pts)
State in just a few words of plain English what the following function does in general:
def mystery(x,y):
    # assume x and y are positive
    z = -1
    for count in range(0,x+1,y):
        z += 1
    return ((count == x) and (y == z))