A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing
 2 years ago
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?
 2 years ago
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?

This Question is Closed

dannyking
 2 years ago
Best ResponseYou've already chosen the best response.0It'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)

Daire
 2 years ago
Best ResponseYou've already chosen the best response.0From 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

kTwitch
 2 years ago
Best ResponseYou've already chosen the best response.1// 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.
Ask your own question
Ask a QuestionFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.