I am trying to write a program for a physics lab that can round off a function to 3 sig figs. I have tried using the round function and other methods mentioned in the other post, but it does not work. The answer to the other question only covers 1 sig fig, not 3. I need it to float when it rounds off numbers. For example, 0.4324 rounds to .432, 0.0002443 rounds to .000244, and 132300 rounds to 132000. I don't want it to print the value, but instead round it and then store it in a variable, as I need it to be rounded off at intermediate steps
m = float(input("Enter mass: "))
a = float(input("Enter acceleration: "))
i = m*a
n = 3
print('{:g}'.format(float('{:.3g}'.format(i))))
that is the program I wrote to calculate force to 3 sig figs. This is the output
Enter mass: 4523
Enter acceleration: 2345
1.06e+07