How to find averages?

how to find the median
how to calculate average percentage
how to calculate average in excel
fraction average calculator
how to find the mean
how to find the mode
average formula
average math

I'm trying to make a program to find the Mean average with a set of numbers. It works at the moment but I was wondering if there is any way to make it easier or cleaner. It is pretty messy and bad. Is there anyway I can use loops or anything to make it easier?

NON = raw_input("How many numbers are there? ")
NON = int(NON)

if NON == 2:
    n1 = raw_input("First Number: ")
    n1 = int(n1)
    n2 = raw_input("Second Number: ")
    n2 = int(n2)
    mean = (n1 + n2)/2
    print mean
    print mean

It keeps going after this, all the way up to 15. I just made it manually.

A common way of handling this is with a for() loop

NON = raw_input("How many numbers are there? ")
NON = int(NON)
sum = 0
for i in range(NON):
    number = raw_input("Enter Number #"+str(i)+": ")
    number = int(number)
    sum += number
average = sum / NON
print("Average is: "+str(average))

How to Calculate the Mean Value, They tell us what is the most typical number in a data set, or which number best represents all the numbers in the data set. How to Find the Mean. Count the  Calculating an average is one of the easiest to solve problems in math. The numbers in the problem have to be added together and then divided. Add all of the available numbers together. For example, if the numbers are 80, 95, 100, 77 and 90, the total is 442. Check how many items are factors in the problem.

You can just write it so that the user can just indefinitely input numbers:

numbers = []
while True:
    numbers.append(int(raw_input("What is the next number?")))
    done = raw_input("Are you done? (Y/N) ")
    if done.lower() == "y":
print("The average is {}".format(sum(numbers)/len(numbers)))

Mean Calculator, What does it mean to calculate the average or mean? Technically, you're dividing the sum of the values you're working with by the count (or quantity) of number in  So if you read the problem carefully, all you have left to do to find the average is divide the sum or total of the data (93 minutes) by the number of data points (7): 93 minutes ÷ 7 = 13.2857142857 minutes

Try a function. Function will group the codes and can be used to call multiple of times.

An example

def average(number1, number2):
    return (int(number1) + int(number2)) / 2

NON = raw_input("How many numbers are there? ")
NON = int(NON)

    if NON == 2:
        n1 = raw_input("First Number: ")
        n2 = raw_input("Second Number: ")
        print average(n1,n2)

How to Find an Average, What is an average? The term average has a number of different meanings. Most generally, it is a single number that is used to represent a collection of numbers. The average (mean) is equal to the sum of all the data values divided by the count of values in the data set. Average = Sum / Count. = 268 / 16. = 16.75. Make a Request. Get a Widget for this Calculator. © Calculator Soup.

Try to store the user's input in an array then perform the following:

sum = 0
list = [11,22,33,44,55,66,77]
for num in list:
    sum = sum +num
average  = sum / len(list)
print ("Average of list element is ", average )

Average Calculator, To find the (mean) average price of a loaf of bread in the supermarket, for example, first record the price of each type of loaf: White: £1; Wholemeal: £1.20  To determine an average, first add together all the numbers in the set. For example, if your set is 1, 2, 3, and 4, you would add all of those numbers together to get 10. Next, count how many numbers are in the set - in this case, 4. Divide your sum by the amount of numbers in the set. The result is your answer.

Averages: Mean, Median and Mode, Calculating averages is a simple process that involves adding numbers together and dividing Duration: 1:44 Posted: Jun 9, 2009 Calculate the average of numbers in a contiguous row or column. Do the following: Click a cell below, or to the right, of the numbers for which you want to find the average. On the Home tab, in the Editing group, click the arrow next to AutoSum , click Average, and then press Enter.

Math Help : How to Calculate an Average, Introduction to averages and algebra problems involving averages. how can i find the Duration: 8:37 Posted: Apr 24, 2011 The average is simply the sum of the numbers in a given problem, divided by the number of numbers added together. For example, if four number are added together their sum is divided by four to find the average or arithmetic mean.

Averages (video), Arithmetic mean definition. How to find the arithmetic mean. Hundreds of elementary stats articles and definitions, videos, free homework help  The average of a set of numbers is simply the sum of the numbers divided by the total number of values in the set. For example, suppose we want the average of 24,55, 17, 87 and 100. Simply find the sum of the numbers: 24 + 55 + 17 + 87 + 100 = 283 and divide by 5to get 56.6. A simple problem such as this one can be done by hand without too much trouble, but, for more complex numbers involving many decimal places, it is more convenient to use this calculator.

  • Welcome to StackOverflow! We are not a code reviewing service. If you don't have a problem you can ask your question over here →
  • You seem to know what loops are, perhaps doing a quick Google search will help? We aren't here to write code for you, you
  • Easier in what sense? Shorter? Your code could be done in fewer lines by combining some operations that are now being done in multiple lines, but everything your code does must get done in order to get the right answer.
  • most elegant solution here, but there is a small typo with the format and append parenthesis
  • Thank you. "Are you done? (Y/N)" didn't feel elegant when I wrote it anyhow.
  • You still need a user input to break the loop in that case, or the script won't support an indefinite number of inputs
  • Take a look at Kingsleys answer; actually a better approach, but didn't look so appealing at first glance :D
  • User has to pick the number of inputs ahead of time for that, which I was trying to avoid. Agree that it is better to do it that way if you accept that constraint.
  • Except the function you wrote doesn't compose to averaging larger numbers of values...
  • @ShadowRanger Thanks for pointing it out. Didn't really understand the question. thought he only wants to make it cleaner and easier. He's asking for 'sets' and everyone is giving him a 'list'. Sets doesnt allow repeat while list does.