ex 1.3
This commit is contained in:
parent
a0c6bc139e
commit
784349ec36
17
pcost.py
Normal file
17
pcost.py
Normal file
@ -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}")
|
||||
Loading…
x
Reference in New Issue
Block a user