20前面的引号有标红,运行不了,谁能告诉我怎么回事?

【问题描述】
人口增长问题:按照每年0.1%的增长速度,我国现有人口13亿,10年后将有多少人口?编写一个程序,其功能为:根据下面的公式计算我国10年后的人口数,并输出计算结果。
p=a*(1+rate)n
其中,a=13亿,rate=0.1%, n=10
[输入] a,rate, n的值
[输出] 10年后的人口数
[提示]使用数学函数pow(x,y)实现乘方计算(即xy),结果使用浮点数表示。另外,百分数0.1%不能直接输入,可输入为0.001。

【输入提示】"Input population now:"      "Input rising_rate:"   "Input n:"
【输出形式】"{}years later, population={:.2f}hundred million."
【输入输出示例】注:带下划线的数据为输入内容

Input population now:13.56
Input rising_rate:0.002
Input n:20
20years later, population=14.11hundred million.

我写的
a=input("Input population now:")
b=input("Input rising_rate:")
c=input("Input n:")
pow(1+rate,n)
p=eval(a)*eval(1+rate)**eval(n)
print("{20}years later,population={:.2f}hundred million."format(p,n))


a= eval(input("Input population now:"))
rate=eval(input("Input rising_rate:"))
n=eval(input("Input n:"))
p=a*pow(1+rate,n)
print("{}years later,population={:.2f}hundred million".format(n,p))

结果:

img

如果觉得答案对你有帮助,请点击下采纳,谢谢~

格式化输出应该是字符串''.format() 点号放到引号外

{20}改为{}