Mar-03-2019, 08:18 PM
(Mar-03-2019, 06:50 PM)FloppyPoppy Wrote: how to #1 have these floating point numbers be not so largeUse string formatting,f-string Python 3.6-->.
>>> d = {'Quartz': 0.06999999999999984, 'Hydrogen': 0.040000000000000036, 'Iodine': 0.02999999999999997, 'Aluminum': 0.050000000000000044} >>> print(f'Value of Quartz is {d["Quartz"]:.2f}') Value of Quartz is 0.07
(Mar-03-2019, 06:50 PM)FloppyPoppy Wrote: #2 how to then print out the item in the dictionary that holds the largest number
>>> d = {'Quartz': 0.06999999999999984, 'Hydrogen': 0.040000000000000036, 'Iodine': 0.02999999999999997, 'Aluminum': 0.050000000000000044} >>> max(d, key=d.get) 'Quartz'