Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to round and only have 1 number after the decimal when using the text() widget in python

How do I only keep 1 number after the decimal when in situation like this :

lbl_recu.insert(END, f"\n\nElectricity:")
lbl_recu.insert(END, f"\n=====================================================")
lbl_recu.insert(END, f"\n-Normal Tariff 1000 @(0.098kWh/c) :\t\t {price}")
lbl_recu.insert(END, f"\n-Additional Tariff @ (+0.115c/kWh) :\t\t   {price2}")
lbl_recu.insert(END, f"\n-T.V.H :\t\t                        {tax}")
lbl_recu.insert(END, f"\n-Sub-Total :\t\t                      {total}")
lbl_recu.insert(END, f"\n\n====================================================")

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Use formaters like

{price:.1}

Price must be a float type

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading