'''menuwithfunctions.py -- a simple menu-driven program Jeff Ondich, 12 Sep 2007 This is a version of menu.py that puts most of the code into separate functions. This is a small illustration of how to break a big problem into smaller sub-problems. ''' import random def printMenu(): print 'A. Tell me a joke' print 'B. Sing me a song' print 'C. Give me a random number from 1 to 10' print def doOperation(response): if response == 'A': print 'Why is 6 afraid of 7?' print 'Because 7, 8, 9.' elif response == 'B': print 'Oh Danny boy, the pipes the pipes are calling...' elif response == 'C': print 'Here you go:', random.randint(1, 10) else: print 'Please choose A, B, or C next time' printMenu() response = raw_input('Your choice? ') doOperation(response)