June 2018
Beginner
508 pages
13h 8m
English
Imagine that you have written an e-commerce website. You have displayed the product prices all over the pages. Imagine that the prices in your database are stored with no VAT (sales tax), but you want to display them on the website with VAT at 20%. Here's a few ways of calculating the VAT-inclusive price from the VAT-exclusive price:
# vat.pyprice = 100 # GBP, no VATfinal_price1 = price * 1.2final_price2 = price + price / 5.0final_price3 = price * (100 + 20) / 100.0final_price4 = price + price * 0.2
All these four different ways of calculating a VAT-inclusive price are perfectly acceptable, and I promise you I have found them all in my colleagues' code, over the years. Now, imagine that you have started selling your ...
Read now
Unlock full access