Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,870 questions

51,793 answers

573 users

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 155 views
2 answers 152 views
1 answer 176 views
1 answer 138 views
1 answer 165 views
1 answer 151 views
1 answer 249 views
...