« Boston Python puzzles

Mini-Golf

This is a 9-hole game of Python mini-golf. The goal is to create a series of 9 functions, each of which takes the output of the previous hole as the input. This is supposed to be useful for beginners, so it provides a tour of Python's built-in functions: http://docs.python.org/2/library/functions.html

def hole0(your_name):
    # your_name should be a string of at least 3 letters
    # create a function that divides it into 3 strings of equal size (smallest parts first if not divisible by 3)
    # hint: check out the built-in len() function
    return your_name_parts

def hole1(your_name_parts):
    # this function takes as input the output of the hole0() function
    # convert those 3 strings into 3 lists of their letters
    # hint: check out the builtin list() function
    return letters

def hole2(letters):
    # sort each of the 3 lists of letters alphabetically
    # hint: check out sorted() function and also the list.sort() method, and learn what "sorting in place" means!
    return sorted_letters

def hole3(sorted_letters):
    # convert each letter list into list of ASCII codes
    # hint: ord()
    return ASCII

def hole4(ASCII):
    # convert these ASCII integers into strings
    # hint: str()
    return ASCII_str

def hole5(ASCII_str):
    # join each ASCII_str as a single string
    # hint:  look up the join() method
    return joined_number_strings

def hole6(joined_number_strings):
    # add a decimal point to the beginning of each of the 3 strings
    # hint:  check out the builtin string operations (like '+')
    return point_stuff

def hole7(point_stuff):
    # now convert each into a float
    # hint: float()
    return float_stuff

def hole8(float_stuff):
    # and finally, convert into your Python Name Color
    # multiply each of these 3 floats by 255 to form an RGB value
    # hint: you will need the int() function
    # show me your color to claim your candy!
    # bonus points:  write code that actually outputs a square of this color
    return RGB