```
WEEK08: more top-down design
---------------------------------------------------------------
W: quiz 3 back, finish tic-tac-toe design, function practice

REVIEW:

- Quiz 3 back, midterm grades...
- Lab 7 (hangman) design.py files due this week
- "python design.py" should run without errors!!!
- functions that are only one line are probably not good functions
(it's expensive to call a function)
- this is NOT a good design:

def main():
playGame()

def playGame():
"""plays the game"""
return

FUNCTIONS:

- quiz next week and final will include "write a function..." questions
as well as stack diagram functions

- here are some good practice problems!

Write these functions and a main() to test them
-----------------------------------------------

def getPasswd(minlen, numdigits):
"""
get new password from user...must be at least minlen
long and have at least numdigits digits in it (0-9)
"""

def countLetter(letter, text):
"""count and return number of letter in text"""

def double(L):
"""assume L is a list of numbers, double each"""

def asciigraph(L):
"""make simple histogram of L to terminal"""

def partyInvites(names):
"""print out invitations, given list of names"""

def acrostic(text):
"""get and return first letter of each word in text"""

"""ask the given yes/no question, return True if response is yes"""

def getInteger():
"""get and return int from user, loop until valid input"""

- here are some sample runs of each...

>>> getPasswd(8,2)
not long enough...(need len >= 8)
not enough digits...(need at least 2)
'swarthmore123'

>>> countLetter("e", "we LOVE computer science!!")
5

>>> L = [2,6,9]
>>> double(L)
>>> print L
[4, 12, 18]

>>> asciigraph(L)

0: **** (4)
1: ************ (12)
2: ****************** (18)

>>> partyInvites(["tia", "andy"])

Dear tia,

Bring your laptop and we will write python programs
all night long...

------------------------------

Dear andy,

Bring your laptop and we will write python programs
all night long...

------------------------------

>>> acrostic("thank Gorbachev it's friday!!")
'TGIF'

how about a nice game of chess? pony

how about a nice game of chess? 4

how about a nice game of chess? sure

how about a nice game of chess? y
True

>>> getInteger("Int: ")
Int: 5.5