-2

Help! I am completely new to coding as you can see...lol I need help removing the scientific notation that my code outputs. I would like the results to be displayed as only real numbers...i.e (removing the "e")...I would like to show only maybe 2-4 numbers after the decimal point. Please if anyone can help me with that it would be greatly appreciated.

    Organism_A = 50 

year = 1 


for week in range(1,52*5 + 1):   
    if week%2 == 0: 
        Organism_A/=0.25

    if week%4 == 0:
        Organism_A*=2

    if week%52 == 0: 
        print("At the end of year " + str(year) + " number of Organism A remaining = " + str(Organism_A))
        year+=1

Organism_B = 250 

year = 1 


for week in range(1,52*5 + 1):   
    if week%1 == 0: 
        Organism_B/=0.25

    if week%4 == 0:
        Organism_B*=3

    if week%52 == 0: 
        print("At the end of year " + str(year) + " number of Organism B remaining = " + str(Organism_B))
        year+=1


Organism_C = 1000 

year = 1 


for week in range(1,52*5 + 1):   
    if week%1 == 0: 
        Organism_C/=0.13

    if week%4 == 0:
        Organism_C*=0.75

    if week%52 == 0: 
        print("At the end of year " + str(year) + " number of Organism C remaining = " + str(Organism_C))
        year+=1

Code OUTPUT

Tae Tar
  • 1
  • 1
  • 4
    How exactly do you plan displaying 1.79e225 without using scientific notation? By printing 223 zeroes after 179? – Selcuk Oct 09 '18 at 23:39
  • Please include your output in the question itself, rather than as a screenshot. Also, are you saying you want to hide the exponent? As in, 8.425 would appear to be the same as 8.425 * 10^225? – Athena Oct 09 '18 at 23:40
  • "displayed as only real numbers" doesn't make sense. 1.2e-5 and 0.000012 are two notations for the same real number. – user2357112 Oct 09 '18 at 23:41
  • @user2357112 Looks like it's a duplicate and you have [python] gold badge. –  Oct 10 '18 at 00:12

1 Answers1

0

You might use string formatting as explained here.

x = 1.011111111e23

print('{:.4e}'.format(x))

gives 1.0111e+23 .only have 4 digits after the decimal point

Khalil Al Hooti
  • 4,207
  • 5
  • 23
  • 40