#population
startOrg = int(input("How many organisms would you like to start with? "))
avgDaily = int(input("What rate of increase would you like? Enter a number
1-100: "))
days = int(input("How many days would you like to multiply? "))
i = 0
newOrgs = 0
day = 0
newOrgs1 = 0
avgDaily1 = avgDaily / 100 + 1
print("{0:<10}" "{1:>10}".format("Days", "Population"))
print("{0:<10}" "{1:>10}".format(day, startOrg)
for i in range(days):
print("{0:<10}" "{1:>10}".format(day, newOrgs1))
newOrgs1 = avgDaily1 * (newOrgs1 * avgDaily1)
day = day + 1
我一直遇到基于范围(天)冒号的语法错误:..
我确定我的数学中有很多错误,但我只是想弄清楚这个。
答案 0 :(得分:2)
你在第二个印刷声明中错过了一个“)”。
#population
startOrg = int(input("How many organisms would you like to start with? "))
avgDaily = int(input("What rate of increase would you like? Enter a number 1-100: "))
days = int(input("How many days would you like to multiply? "))
i = 0
newOrgs = 0
day = 0
newOrgs1 = 0
avgDaily1 = avgDaily / 100 + 1
print("{0:<10}" "{1:>10}".format("Days", "Population"))
print("{0:<10}" "{1:>10}".format(day, startOrg))
for i in range(days):
print("{0:<10}" "{1:>10}".format(day, newOrgs1))
newOrgs1 = avgDaily1 * (newOrgs1 * avgDaily1)
day = day + 1
整洁的代码。