我正在尝试从结果中删除指数数字

时间:2018-10-09 23:37:02

标签: python scientific-notation

帮助!如您所见,我是编码的新手...大声笑我需要帮助删除我的代码输出的科学记法。我希望结果只显示为实数...即(删除“ e”)...我只想显示小数点后的2-4个数字。如果有人可以帮助我,将不胜感激。

    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

1 个答案:

答案 0 :(得分:0)

您可以按照here所述使用字符串格式。

x = 1.011111111e23

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

给出1.0111e + 23。小数点后只能有4位数字