-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAverage.py
More file actions
41 lines (31 loc) · 847 Bytes
/
Average.py
File metadata and controls
41 lines (31 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!usr/bin/python#coding=utf-8
#计算平均值
# /******************************************************************************
# * Compilation: pythoncAverage.py
# * Execution: python Average < data.txt
# *
# * Reads in a sequence of real numbers, and computes their average.
# *
# * % python Average
# * 10.0 5.0 6.0
# * 3.0 7.0 32.0
# * [Ctrl-d]
# * Average is 10.5
# *
# * Note [Ctrl-d] signifies the end of file on Unix.
# * On windows use [Ctrl-z].
# *
# ******************************************************************************/
__author__ = 'Administrator'
import sys
reply=[]
sumd=0
while True:
try:
reply.append(float(input()))
except EOFError:
for x in reply:
sumd += x
average = sumd/len(reply)
print("Average is",average)
break