Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion squares.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Computation of weighted average of squares."""


import argparse

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


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Inputs for weighted average of squares")
parser.add_argument("--numbers", nargs="+", type=int, help="List of numbers")
arguments = parser.parse_args()

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

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

result = average_of_squares(numbers, weights)
Expand Down