forked from mGalarnyk/Python_Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_process_numbers.py
35 lines (31 loc) · 921 Bytes
/
3_process_numbers.py
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
# -*- coding: utf-8 -*-
"""
Michael Galarnyk
Write a program called “process_numbers.py”
that repeatedly reads numbers input by
the user until the user types “done”.
After the user has entered “done”,
print out the total, count, maximum,
minimum, and average of the entered numbers.
"""
user_input = ''
total = 0;
count = 0;
maximum = None;
minimum = None;
while (user_input != 'done'):
user_input = raw_input('Enter a number or enter done\n');
if user_input != 'done':
total += float(user_input);
if (user_input == 'done'):
average = total / float(count);
break;
count += 1
if maximum is None or user_input > maximum:
maximum = user_input
if minimum is None or user_input < minimum:
minimum = user_input
print 'count: %d \n' %count
print 'average%g \n' %average
print 'maximum:%s \n' %maximum
print 'minimum:%s \n' %minimum