If you knew how to iterate through a dictionary, index the dictionary with a key, and understand the dictionary, this would be direct
>>> total = {key: price * stock[key] for key, price in prices.items()}
>>> total
{'orange': 48.0, 'pear': 45, 'banana': 24, 'apple': 0}
Python (< Py 2.7), dict
>>> dict((key, price * stock[key]) for key, price in prices.items())
{'orange': 48.0, 'pear': 45, 'banana': 24, 'apple': 0}
2.X 3.X, iteritems
{key: price * stock[key] for key, price in prices.iteritems()}
, sum
>>> sum(price * stock[key] for key, price in prices.items())
117.0