Temperature Conversion
Posted: Sat Apr 20, 2024 1:26 am
I would appreciate some help with getting this Python code correct. The following code seems to work, except I’m not getting consistent results with decimal places.
Sometimes the result might be xx.xx (2 decimal places), and sometimes it might be something like this (xx.xxxxxxxxx) both from the same code.
I would like to see examples of how this code can be written to control decimals as follows:
No decimal (xx)
1 decimal (xx.x)
2 decimals (xx.xx)
Also, do I need a “default=xx” after float? .getValue(float, default=xx)
- Code: Select all
# Conversion ºC to ºF
celsiusVar = indigo.variables[123456789]
tempVar = celsiusVar.getValue(float)
indigo.variable.updateValue(987654321,str(tempVar * 9/5 + 32))
Sometimes the result might be xx.xx (2 decimal places), and sometimes it might be something like this (xx.xxxxxxxxx) both from the same code.
I would like to see examples of how this code can be written to control decimals as follows:
No decimal (xx)
1 decimal (xx.x)
2 decimals (xx.xx)
Also, do I need a “default=xx” after float? .getValue(float, default=xx)