Can anyone help me get started on converting a float to a fraction?

In theory all you've got to do is use the decimal as the numerator, and then count up the number of digits in that numerator before putting a 1, followed by the same number of zeros on the bottom. So 0.25 becomes 25/100, for example. If you wanted to reduce it further than that, you would have to go round a loop looking for the largest common factor; starting, in this case with 25. Also in this case, you would only have to go round it once.

Hello guys, hope you all fine,,
I have a problem when coding using python and opencv.
My project is to track the ball in model soccer pitch using raspberry pi ...