anonymous
  • anonymous
n = int(input ("enter the number input; ")) sumN = 0 for nCount in range(n): inputNumber = int(input("Enter your next number; ")) sumN += inputNumber average = sumN/n print "The sum of the number is; ",sumN print "The average of the number is; ",average Can anybody explain this to me?
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
It's hard to say without knowing what language it is in, because it depends what the 'range()' function does, but I think this is a function to calculate the mean (i.e. average) of all the numbers from 1 to the number you input. E.g. if you input 5, it would add (1+2+3+4+5) and then divide it by 5 to get 5. The average will always be the input. It also tells you the sum of the numbers from 1 to your input. (assuming range returns the numbers from 1 to n)
anonymous
  • anonymous
From what I can gather the program is does this: -Ask user to input a number (n) -Creates a loop that asks the user to input more numbers. The number of loops is determined by the first input number i.e If the first number entered is 5 the program asks for 5 more numbers. -As the numbers are entered they are added to a total. (sumN) -When the loop finishes the average is calculated using the total divided by the first number (average = sumN/n) -The program then prints the values of the total and average. What programming language is this written btw? I'm guessing Python? If so, this should explain the range() function. http://docs.python.org/release/1.5.1p1/tut/range.html
anonymous
  • anonymous
// Receives input from user, turns it into an int, and stores it in n. n = int(input ("enter the number input; ")) // Declares 'sum' variable and initializes it as zero. sumN = 0 // For every number from 1 (or 0) to n.. for nCount in range(n): // Receive number from user to add to sumN. inputNumber = int(input("Enter your next number; ")) sumN += inputNumber // Find the average of all of the numbers entered. average = sumN/n // Output information. print "The sum of the number is; ",sumN print "The average of the number is; ",average Essentially, n acts as the amount of numbers to find the average of.

Looking for something else?

Not the answer you are looking for? Search for more explanations.