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!

$ cat README.functions 

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"""


def askYesNo(question):
  """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)
password: hello
not long enough...(need len >= 8)
password: lkdjfljdflkdjf
not enough digits...(need at least 2)
password: swarthmore123
'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,

    Join us this Saturday night at 9pm for a party!
  Bring your laptop and we will write python programs
  all night long...

                       Your friends @ SwatCS
------------------------------

  Dear andy,

    Join us this Saturday night at 9pm for a party!
  Bring your laptop and we will write python programs
  all night long...

                       Your friends @ SwatCS
------------------------------


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


>>> askYesNo("how about a nice game of chess? ")
how about a nice game of chess? pony

Please answer either y or n!

how about a nice game of chess? 4

Please answer either y or n!

how about a nice game of chess? sure

Please answer either y or n!

how about a nice game of chess? y
True


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

Please enter an integer!!

Int: pony

Please enter an integer!!

Int: 4
4