Skip to content

Commit 989697e

Browse files
committed
Answers UCL-MPHY0021-21-22/RSE-Classwork#33 - Now includes weights as an optional input
1 parent 37ed1f8 commit 989697e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

squares.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ def convert_numbers(list_of_strings):
5151

5252

5353
if __name__ == "__main__":
54-
parser = ArgumentParser(description="Mean of squared numbers")
54+
parser = ArgumentParser(description="Weighted mean of squared numbers")
5555
parser.add_argument("numbers", nargs='+', type=float, help="the list of numbers")
56+
parser.add_argument("--weights", "-w", nargs='+', type=float, help="the list of weights")
5657
arguments = parser.parse_args()
5758

58-
result = average_of_squares(arguments.numbers)
59+
result = average_of_squares(arguments.numbers, arguments.weights)
5960

6061
print(result)

0 commit comments

Comments
 (0)