If we want to return a specific number of decimal digits in f-strings we can use the f'{v:.2f}'
where v is our variable. For example:
import numpy as np my_random = np.random.rand(10) for i, n in enumerate(my_random): print(f'The {i} number is {n}')
Now, if we pass the :.2f
we will get 2 decimal places. For example:
for i, n in enumerate(my_random): print(f'The {i} number is {n:.2f}')