Instruction
Good job! Just like with integers, you can control the number of digits reserved for a float variable. Take a look:
exact_temperature = 24.3487935543
print('The exact temperature is {:06.2f} degrees Celsius.'.format(exact_temperature))
Result: The exact temperature is 024.35 degrees Celsius.
The {:06.2f} placeholder means, "Reserve at least 6 characters for the value, two of which will appear after the decimal point. Fill any empty spaces with zeroes." Note that the decimal point (.) also counts as one character.
Also note that 1.45 is actually 1.4499999999999999 in Python, and that's why the result of
print('{:1.1f}'.format(1.45)) will be
1.4, not
1.5.
Exercise
You have a dictionary with the exchange rates for certain currencies. Your task is to print a list like this:
Exchange rates EUR...04.2714 GBP...04.8055 ...
All rates should be 7 characters long and have 4 digits after the decimal point.
Stuck? Here's a hint!
To iterate over the dictionary, you can use:
for key, value in rates.items():
In the for loop, cast the value to float.



