Let A be the average of the numbers in this text file . What is the value of A , rounded to the nearest integer?
Click here to open the file.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The answer is 499 .
Iterate through the list, keeping track of the sum and the total number of integers as you go. When you reach the end of the list, compute the average by dividing the total sum by the number of integers.
Integer Division : When you divide two integers, the result will be rounded down. To preserve the decimal values so you can round correctly, make sure your sum is a non-integer type, such as a float.
Python solution: