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'd zip together the 3 lists to produce <code>velocity, altitude, temperature</code> tuples:</p>

<pre><code>mach_dict['mach'] = mach_per_section = []
for vel, alt, temp in zip(
        mach_dict['velocity'], mach_dict['altitude'], mach_dict['temperature']):
    mach = vel / sqrt(1.4 * 286 * (temp - alt * 0.05))
    mach_per_section.append(mach)
</code></pre>

<p>Unfortunately, your inputs lead to a <code>ValueError: math domain error</code> because for some you'd get a negative value for <code>1.4 * 286 * (temp - alt * 0.05)</code>.</p>

python function dictionary arguments