Skip to content

Commit

Permalink
Answer UCL-RITS#141
Browse files Browse the repository at this point in the history
  • Loading branch information
umitozmen committed Nov 26, 2020
1 parent b1abf12 commit 4129a5d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions week06/average-squares-example/average_squares/squares.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ def convert_numbers(list_of_strings):
if __name__ == "__main__":

parser = ArgumentParser(description="Generate average of squares")
parser.add_argument('--numbers', '-n' , type=str)
parser.add_argument('numbers' , type=int, nargs= '+' help="the list of numbers")
parser.add_argument('--weights', '-w' , type=int, nargs= '+' help="the list of weights")
arguments = parser.parse_args()

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

numbers = convert_numbers(arguments.numbers)
weights = convert_numbers(weight_strings)
numbers = arguments.numbers
if arguments.weights:
weights = arguments.weights
else:
weights = [1]*len(numbers)

result = average_of_squares(numbers, weights)

Expand Down

0 comments on commit 4129a5d

Please sign in to comment.