function using dictionary as argument
<p>I have created a dictionary with values for Velocity, temperature and altitude:</p>

<pre><code>mach_dict = dict(velocity=[], altitude=[], temperature=[])
</code></pre>

<p>Which I use to store values for a flying plain at climb, cruise and descent segments.</p>

<pre><code>mach_dict = {'velocity': [0, 300, 495, 500, 300], 'altitude': [288.15, 288.15, 288.15, 288.15, 288.15], 'temperature': [0, 0, 50, 50, 50]}
</code></pre>

<p>I need to create a function (def) that returns a dictionary that stores the mach number for every segment. </p>

<p>To estimate <code>Mach</code> I use the formula:</p>

<pre><code>Mach = velocity / sqrt(1.4 * 286 * (Temperature - altitude * 0.05))
</code></pre>

<p>Can anybody help on that? </p>

<p>Technically, this is modifying the passed in dictionary, and the <code>return</code> is unnecessary.  </p>

<pre><code>from math import sqrt

def func(d):
    machs = []
    for v, a, t in zip(d['velocity', d['altitude'], d['temperature']):
        mach = v / sqrt(1.4 * 286 * (t - a * 0.05))
        machs.append(mach)
    d['mach'] = machs
    return d
</code></pre>

python function dictionary arguments