Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
26
Task/Currency/Python/currency.py
Normal file
26
Task/Currency/Python/currency.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from decimal import Decimal as D
|
||||
from collections import namedtuple
|
||||
|
||||
Item = namedtuple('Item', 'price, quant')
|
||||
|
||||
items = dict( hamburger=Item(D('5.50'), D('4000000000000000')),
|
||||
milkshake=Item(D('2.86'), D('2')) )
|
||||
tax_rate = D('0.0765')
|
||||
|
||||
fmt = "%-10s %8s %18s %22s"
|
||||
print(fmt % tuple('Item Price Quantity Extension'.upper().split()))
|
||||
|
||||
total_before_tax = 0
|
||||
for item, (price, quant) in sorted(items.items()):
|
||||
ext = price * quant
|
||||
print(fmt % (item, price, quant, ext))
|
||||
total_before_tax += ext
|
||||
print(fmt % ('', '', '', '--------------------'))
|
||||
print(fmt % ('', '', 'subtotal', total_before_tax))
|
||||
|
||||
tax = (tax_rate * total_before_tax).quantize(D('0.00'))
|
||||
print(fmt % ('', '', 'Tax', tax))
|
||||
|
||||
total = total_before_tax + tax
|
||||
print(fmt % ('', '', '', '--------------------'))
|
||||
print(fmt % ('', '', 'Total', total))
|
||||
Loading…
Add table
Add a link
Reference in a new issue