From 784349ec360e551b0a6f70cb7559156dfad675a8 Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Wed, 9 Aug 2023 16:59:22 -0500 Subject: [PATCH] ex 1.3 --- pcost.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pcost.py diff --git a/pcost.py b/pcost.py new file mode 100644 index 0000000..30e7e65 --- /dev/null +++ b/pcost.py @@ -0,0 +1,17 @@ +from decimal import Decimal + + +def run(filename: str) -> Decimal: + with open(filename, 'r') as lines: + total = Decimal(0.0) + _, count, price = lines.readline().split() + count = Decimal(count) + price = Decimal(price) + total += count * price + return total + + +if __name__ == '__main__': + filename = 'Data/portfolio.dat' + value = run(filename) + print(f"value = {value}")