Python代码计算多项分式的和
n = int(input('请输入项数n: '))
result = 0
for i in range(1, n+1):
term = 1 / i
result += term
print('{:.2f}'.format(result))
运行上述代码,输入项数n,程序会计算多项分式的和,并保留两位小数输出结果。
原文地址: https://www.cveoy.top/t/topic/WNG 著作权归作者所有。请勿转载和采集!
安全问答是一个知识全球问答,包含丰富的问答知识
n = int(input('请输入项数n: '))
result = 0
for i in range(1, n+1):
term = 1 / i
result += term
print('{:.2f}'.format(result))
运行上述代码,输入项数n,程序会计算多项分式的和,并保留两位小数输出结果。
原文地址: https://www.cveoy.top/t/topic/WNG 著作权归作者所有。请勿转载和采集!