Goal
====

I want to convert all floats to two decimal places regardless of number of decimal places float has **without repeating convert code**.

For example, I want to convert

`50` to `50.00`

`50.5` to `50.50`

without repeating the convert code again and again. What I mean is explained in the following section - research.

Not what this question is about
-------------------------------

This question is **NOT** about:

1. Only limiting floats to two decimal points - if there is less than two decimal points then I want it to have two decimal points with zeros for the unused spaces.
2. Flooring the decimal or ceiling it.
3. Rounding the decimal off.

This question is not a duplicate of [this](https://stackoverflow.com/questions/1995615/how-can-i-format-a-decimal-to-always-show-2-decimal-places%20-%20I%20want%20the%20function%20for%20the%20whole%20program) question.

> 
> That question only answers the first part of my question - convert floats to two decimal places regardless of number of decimal places float has, not the second part - without repeating convert code.
> 
> 
> 

Nor [this](https://stackoverflow.com/questions/1424638/pad-python-floats) question.

> 
> That is just how to add units before the decimal place. My question
> is: how to convert all floats to two decimal places regardless of
> number of decimal places float has without repeating convert code.
> 
> 
> 

Research
========

I found two ways I can achieve the convert. One is using the [`decimal`](https://docs.python.org/3/library/decimal.html) module:

```py
from decimal import *
TWOPLACES = Decimal(10) ** -2
print(Decimal('9.9').quantize(TWOPLACES))

```

Another, without using any other modules:

```py
print(f"{9.9:.2f}")

```

However, that does not *fully* answer my question. Realise that the code to convert keeps being needed to repeat itself? I keep having to repeat the code to convert again and again. Sadly, my whole program is already almost completed and it will be quite a waste of time to add this code here and there so the format will be correct. Is there any way to convert all floats to two decimal places regardless of number of decimal places float has **without repeating convert code**?

Clarification
=============

What I mean by convert is, something like what [Dmytro Chasovskyi](https://stackoverflow.com/users/4473386/dmytro-chasovskyi) said, that I want all places with floats in my program without extra changes to start to operate like decimals. For example, if I had the operation `1.2345 + 2.7 + 3 + 56.1223183` it should be `1.23 + 2.70 + 3.00 + 56.12`.

Also, `float` is a number, not a function.