-
Notifications
You must be signed in to change notification settings - Fork 0
/
AverageCalculator.py
31 lines (28 loc) · 1.3 KB
/
AverageCalculator.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
'''
Task Description:
Develop a simple average calculator program. The program requirement is as follows:
1. Allow users to run your program with three input arguments by passing three values to the
program: a, b and c.
2. Your program will read the three arguments and calculate the average value.
3. After user inputs all the numbers, if the input numbers are invalid, you need to present an error
message “Your input is invalid!”. Otherwise, you need to print out the average value. The output
average value requires to have 2 precisions. For instance, if the value is 23.456, it should print
23.45. If it is 23, it should print 23.00.
NOTE: You have to strictly follow the input and output format.
Assume your program is named as AverageCalculator.py. Example output is as follows:
Example1:
C:\ICT1002\Lab1\AverageCalculator>python AverageCalculator.py 3 4 5
Average:4.00
C:\ICT1002\Lab1\AverageCalculator>python AverageCalculator.py 60 39 92
Average:63.67
C:\ICT1002\Lab1\AverageCalculator>python AverageCalculator.py abc 10 20
Your input is invalid!
'''
import sys
# write your code here
# you can use sys.argv[1] to get the first input argument.
# sys.argv[2] is the second argument, etc.
def AverageCalculator():
pass
if __name__=='__main__':
AverageCalculator()