MCPcopy Create free account
hub / github.com/ActiveState/code / main

Function main

recipes/Python/440625_Simple_Average_Calculation/recipe-440625.py:1–12  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1def main():
2 while True:
3 try:
4 string = raw_input('What numbers should I average? ')
5 words = string.split()
6 numbers = map(float, words)
7 average = sum(numbers) / len(numbers)
8 print 'The average is', average
9 raw_input('Press enter to quit.\n')
10 return
11 except:
12 print 'ERROR: I can only take numbers!'
13
14if __name__ == '__main__':
15 main()

Callers 1

recipe-440625.pyFile · 0.70

Calls 3

mapFunction · 0.85
sumFunction · 0.50
splitMethod · 0.45

Tested by

no test coverage detected