How can I get the average of a range of inputs?
<p>I have to create a program that shows the arithmetic mean of a list of variables. There are supposed to be 50 grades. </p>

<p>I'm pretty much stuck. Right now IÂ´ve only got:</p>

<pre><code>for c in range (0,50):
    grade = ("What is the grade?")
</code></pre>

<p>Also, how could I print the count of grades that are below 50?</p>

<p>Any help is appreciated.</p>

<p>Assuming you have a list with all the grades.</p>

<pre><code>avg = sum(gradeList)/len(gradeList)
</code></pre>

<p>This is actually faster than numpy.mean(). </p>

<p>To find the number of grades less than 50 you can put it in a loop with a conditional statement.</p>

<pre><code>numPoorGrades = 0
for g in grades:
    if g &lt; 50:
        numPoorGrades += 1    
</code></pre>

<p>You could also write this a little more compactly using a list comprehension.</p>

<pre><code>numPoorGrades = len([g for g in grades if g &lt; 50])
</code></pre>

python