Q:

Computing average of scores for strings in a dictionary

How can I write a python program that takes the values for strings in a dictionary with an input of any string and dictionary in the form:
score("a b" , {"a":(1.2) , "b":(3.4)})

and returns the average of the values as a float?

A:

It looks to me like you want:
def score(key_str,dct):
    keys = key_str.split()
    v = sum(dct[key] for key in keys)
    return float(v)/len(keys)

