Skip to content

Commit

Permalink
Answer to UCL-RITS#140
Browse files Browse the repository at this point in the history
  • Loading branch information
umitozmen committed Nov 26, 2020
1 parent 85c570d commit b1abf12
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions week06/average-squares-example/average_squares/squares.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Computation of weighted average of squares."""

from argparse import ArgumentParser

def average_of_squares(list_of_numbers, list_of_weights=None):
""" Return the weighted average of a list of values.
Expand Down Expand Up @@ -51,12 +51,21 @@ def convert_numbers(list_of_strings):


if __name__ == "__main__":
numbers_strings = ["1","2","4"]

parser = ArgumentParser(description="Generate average of squares")
parser.add_argument('--numbers', '-n' , type=str)
arguments = parser.parse_args()

#numbers_strings = ["1","2","4"]
weight_strings = ["1","1","1"]

numbers = convert_numbers(numbers_strings)
numbers = convert_numbers(arguments.numbers)
weights = convert_numbers(weight_strings)

result = average_of_squares(numbers, weights)

print(result)
print(result)




0 comments on commit b1abf12

Please sign in to comment.