numbers = []
line = int(raw_input('Enter number: '))
while line != '':
  numbers.append(line)
  line = raw_input('Enter number: ')
print "Size:" + " " + str(len(numbers))

Hey guys, once again I need some help with a challege.
http://pokit.org/get/img/c00a1897d52de5b36329564861fadb1b.jpg

For your homework, you are given a set of integer data readings, and you need to compute a number of statistical measures over the readings. The measures you need to compute are:

How many values are in the set of readings (Size)
The sum of the values (Sum)
The average (mean) of the values (Average)
The smallest value (Smallest)
The largest value (Largest)

Since there are a lot of these datasets to compute the statistics for, you decide to write a Python program to help you out. Write a Python program to read in multiple lines of input from the user. Each line will contain one integer – the next value in the dataset. Once the user stops entering numbers, your program should print out all of the aforementioned statistics over the entered numbers.

For example:

Enter number: 4
Enter number: 10
Enter number: 7
Enter number:
Size: 3
Sum: 21
Average: 7.0
Smallest: 4
Largest: 10

Can you guys please help me?

Thanks!

When I attempt to add the list up, with sum(), I am unable to as it says that they are not integers. Thats about the biggest problem I have at the moment.
Thank you! :D

You got it right outside the loop. You do not need to have other input outside the loop, just give any value to variable which is not empty string and put the raw_input first inside the loop.

Edited 4 Years Ago by pyTony

This article has been dead for over six months. Start a new discussion instead.