Share price
===========

You spent all your saved money to buy some shares.

You bought it for `invested`, and want to know how much it's worth, but all the info you can quickly get are just the change the shares price made in percentages.

Your task:
----------
Write the function `sharePrice()` that calculates, and returns the current price of your share, given the following two arguments:

- `invested`(number), the amount of money you initially invested in the given share

- `changes`(array of numbers), contains your shares daily movement percentages

The returned number, should be in string format, and it's precision should be fixed at 2 decimal numbers.

Have fun!

>**Hint:** Try to write the function in a functional manner!

Difficulty: introductory

Starter code:

def share_price(invested, changes):
	

Solutions:
def share_price(invested, changes):
    for change in changes:
        invested = invested * (100 + change) / 100.0
    return format(invested, '.2f')

def share_price(invested, changes):
    sum=float(invested)
    for i in changes:
        sum=sum+(sum/100*i)
    return str('{:.2f}'.format(float(sum)))

def share_price(invested, changes):
    for change in changes:
        invested = invested + ( invested * (change/100.00) )
    return "%.2f" % invested 
    


import operator
from functools import reduce


def share_price(invested, changes):
    multipliers = (1.0 + c / 100.0 for c in changes)
    product = reduce(operator.mul, multipliers, 1.0)
    return '%.2f' % (invested * product)


from functools import reduce

def share_price(invested, changes):
    r = reduce(lambda acc, x: acc + x * acc * 0.01, changes, invested)
    return '{:.2f}'.format(r)

from functools import reduce
def share_price(invested, changes):
    return '{:.2f}'.format(
        reduce(lambda a, b: a + (a * (b / 100.0)), changes, invested))