While performing arithmetic operations on arrays, and the output is an integer why does the output display 1. or 11. instead of 1.0 or 11.0? Is there a way to display the integer with the floating-point value such as instead of 1. or 11. as 1.0 or 11.0?
2 Answers
In Python, you can format floating numbers to a specific decimal places like this:
pi = 3.1415926
formatter = "{0:.2f}"
output = formatter.format(pi) # 3.14
You can read more about this here: https://mkaz.blog/code/python-string-format-cookbook/
int(...)the result