Oct-04-2018, 04:23 PM
(Oct-04-2018, 04:16 PM)gruntfutuk Wrote: BAD:
print(end='In 1 year, the tuition will be $' + str(totalOnePrice) + '.\n')
BETTER:
print(end='In 1 year, the tuition will be $' + '{:.12f}'.format(totalOnePrice) + '.\n')
but usingend=<str>
in such a way is, imho, a very bad practice.
PS. Using floats when dealing with money is not usually a good idea. Work in cents or use the decimal package.
BEST:
print('In 1 year, the tuition will be ${:.12f}.\n'.format(totalOnePrice))
end
seems somehow redundant.PS I know,
f
-formattingprint(f'In 1 year, the tuition will be ${totalOnePrice:.12f}.\n')
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.