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>You can <code>zip</code> the list values in the dictionary and compute the new key <code>mach_number</code> using a <em>list comprehension</em>:</p>

<pre><code>import math

def compute_mach(velocity, altitude, temperature):
    return velocity/math.sqrt(1.4*286*(temperature-altitude*0.05))

mach_dict['mach_number'] = [compute_mach(v, a, t)  for v, a, t in zip(mach_dict['velocity'], 
                                                                      mach_dict['altitude'], 
                                                                      mach_dict['temperature'])]
</code></pre>

python function dictionary arguments