Skip to content

Commit

Permalink
using it with arguments in command line UCL-RITS#140 @kyrlazari @wjl1…
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidScobie committed Nov 26, 2020
1 parent 45f37d1 commit 19e4096
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions week06/average-squares-example/average_squares/squares.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Computation of weighted average of squares."""
import math
from argparse import ArgumentParser
import sys

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 +53,18 @@ def convert_numbers(list_of_strings):


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


numbers_strings = str(sys.argv)
floats = [x for x in sys.argv[1:]]

weight_strings = ["1","0.5"]

numbers = convert_numbers(numbers_strings)
numbers = convert_numbers(floats)
weights = convert_numbers(weight_strings)

result = average_of_squares(numbers, weights)
print(result)


0 comments on commit 19e4096

Please sign in to comment.