2.5 The power to make progress every day

There are 365 days in a year, based on the ability value of the first day, recorded as 1.0. When studying hard, the ability value increases by N‰ compared to the previous day; when not studying, the ability value decreases by N‰ compared to the previous day due to forgetting and other reasons. If you work hard every day or let it go, what is the difference in ability value in a year? Wherein, the value range of N is 1 to 10, and N may be a decimal. ‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬ ‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬

Obtain the user input N, calculate the ability value and the ratio between abilities after working hard every day and letting go every day for 365 days, where the ability value retains 2 decimal places, and the ratio between abilities outputs an integer, and the output results use the "comma + space" format.

N = float(input("请输入一个从1到10的数:"))
change = N/1000
up = down = 1
for i in range(1,366):
    up = up*(1+change)
    down = down*(1-change)
ratio = int(up/down)
print("每天努力和每天放任365天后的能力值及能力间比值为:%.2f," % up,"%.2f," % down,ratio)

The result is

 

Guess you like

Origin blog.csdn.net/m0_61463713/article/details/120286475