How to represent value in scientific notation with Python

3 Answers

0 votes
n1 = float(99000000.00000)
n2 = float(0.00000088)

print(format(n1,'.1E'))
print(format(n2,'.1E'))




'''
run:

9.9E+07
8.8E-07

'''

 



answered Apr 14, 2021 by avibootz
0 votes
n1 = float(99000000.00000)
n2 = float(0.00000088)

print(f"{n1:.1E}")
print(f"{n2:.1E}")




'''
run:

9.9E+07
8.8E-07

'''

 



answered Apr 14, 2021 by avibootz
0 votes
import numpy as np

n1 = float(99000000.00000)
n2 = float(0.00000088)

print(np.format_float_scientific(n1, precision = 1, exp_digits=4))
print(np.format_float_scientific(n2, precision = 3, exp_digits=4))




'''
run:

9.9e+0007
8.8e-0007

'''

 



answered Apr 14, 2021 by avibootz

Related questions

2 answers 188 views
2 answers 182 views
1 answer 204 views
1 answer 165 views
1 answer 182 views
1 answer 169 views
1 answer 272 views
...