def dotProduct(vector1, vector2):
    """Caclulate and return dot product of vectors.

    Calculate and return the dot product (inner product) of the two vectors
    (Python dict type).

    :param vector1: vector 1
    :type vector1: dict
    :param vector2: vector 2
    :type vector2: dict
    :returns: dot product

    >>> dotProduct({1:1,2:2,3:3,4:4}, {2:2,3:3})
    13
    >>> dotProduct({1:1,2:2,3:3,4:4}, {2:2.0,3:3.0})
    13.0
    """
    # order doesn't affect result - just need to compare the two
    # should be faster to iterate over shorter then search in longer dict
    a, b = sorted([vector1, vector2], key=len)
    return sum([v * b.get(k, 0) for k, v in a.iteritems()])