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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay