DEV Community

Cover image for Optical Investment Calculator
Mauro Peluso
Mauro Peluso

Posted on

Optical Investment Calculator

Well, being an optician like myself, those who are also in the field will know about the changes that sometimes need to be made to the dioptres in ophthalmic prescriptions. As simple as it may seem, it would be useful to have a #Python function to perform this quickly. Here's my solution.

esf = -1.50
cil = -0.50
eje = 90
if eje >= 90:
    eje -= 90  
else:
    eje += 90

esfinv = esf+cil

if cil > 0:
    cil = -cil  
else:
    cil = abs(cil)  



print(f"esferico {esfinv} x cilindrico {cil} en {eje}°")
In this example the results are: *esferico -2.0 x cilindrico 0.5 en 0°*
Enter fullscreen mode Exit fullscreen mode

Thank you in advance for viewing this post. If you have any feedback, whether positive or negative, I look forward to reading it. Namaste.

Top comments (0)