Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
35 lines (31 loc) · 921 Bytes

File metadata and controls

35 lines (31 loc) · 921 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.