I just started learning Python in school. I'm trying to write a program to do the simple calculation that determines my little sister’s insulin dosing (she just got diagnosed with Type 1 diabetes).
The equation looks like this:
(Current Blood Glucose - Target Blood Glucose) / her correction factor
Ex. She has a target of 120 and a correction factor of 80. When measured, the BG happens to be 260 so:
(260-120)/80 = 1.75
(which means 1.75 units of insulin)
Here's where I'm stuck - there's a diabetes safety thing where the answer is rounded down to the nearest .5 (in the above example this would mean 1.5 units). However, if the answer is >.85 then it is rounded up
Ex. 1.86 would be rounded to 2.00
I've tried several things but I'm either wrong in my syntax or it seems to grow into a really hard (long) way of doing this.
Does anyone know if there is a library/function to simplify this or have an idea about how to do this operation efficiently?