For older version of Python, one can print the string as such:
>>> print('X = %6.4f' % 12312312.423141)
X = 12312312.4231
And in Python < 3.6, putting a float into a formatted string and printing the string. In modern python, one could have done:
>>> print('X = {num}'.format(num=round(12312312.423141, 4)))
X = 12312312.4231
But that's explicitly rounding the float to 4 decimal points. Is there a way to print the float as in the old way by stating the 6-place field to the 4 decimal points? E.g. https://stackoverflow.com/a/15215445/610569
For Python > 3.6, how about fstring? Would it look like this?
>>> num=12312312.423141
>>> print(f'X = {num:6.4f}')