How Can We Help?

Power of the Cumulative Progress

Power of the Cumulative Progress

There are 365 days in a year. If you make the progress of 1% every day, what is the cumulative progress in a year?

There are 365 days in a year. If you regress by 1% every day, what is the cumulative regression in a year?

This question is simple if you see it as a mathematical problem, and it can be solved more easily by compiling it as a Python program.

Take the progress and regression of 0.001 as an example and round the values to the nearest hundredth. Enter the following code:

#DayDayUpQ1.py

dayup = pow(1.001, 365)

daydown = pow(0.999, 365)

print(“dayup:{:.2f},daydown:{:.2f}”.format(dayup, daydown))

The output is as follows:

dayup= 1.44

daydown=0.69

You can see the accumulation of 0.001. This is what the most people may expect and what most people may get after one year’s efforts.

If you want to change the daily progress, you can add a variable instead of repeatedly modifying the setting of the pow function.

#DayDayUpQ2.py

dayfactor = 0.005

dayup = pow(1+dayfactor, 365)

daydown = pow(1-dayfactor, 365)

print(“dayup:{:.2f},daydown:{:.2f}”.format(dayup, daydown))

As shown in the preceding code, the daily progress is changed to 0.005, and the output is as follows:

dayup =6.17, daydown =0.16

From the output, you can see that a substantial change has occurred if the daily progress is changed from 0.001 to 0.005. But can you make the progress of 5‰ every day?

 

Now, change the value of dayfactor to 0.01 and see what the output is.

 

dayup=37.78

 

Is this number shocking? Surely, there is nothing wrong with the computing.

 

Now, change the period from 365 days to 730 days and see what the output is.

dayup=1427.59

Unbelievable? But this is true.

Here comes the next question.

We don’t work or make progress every day. For example, we usually work on weekdays but rest on weekends. We may make progress of 0.01 every day on weekdays and regress by 0.01 very day on weekends. In this case, what is the cumulative progress in a year?

#DayDayUpQ3.py

dayup = 1.0

dayfactor = 0.01

for i in range(365):

if i % 7 in [6,0]:

dayup = dayup*(1-dayfactor)

else:

dayup = dayup*(1+dayfactor)

print(“Power on weekdays:{:.2f} “.format(dayup))

Run the code. The output is as follows:

4.63

Still, the progress of 4 has been made. Compared to the progress of 37 achieved by making the progress of 0.01 every day, however, there is a large gap. As you can see, this is the power of persistence.

And here is the last question.

Assume that there are two people, A and B. A keeps making progress of 0.01 every day, and B rests on weekends (regress by 0.01 every day). Then, how much progress does B need to make every day on weekdays to catch up with A?

The amount of data is not large, so we can obtain the result by enumeration.

Enter the following code:

#DayDayUpQ4.py

def dayUP(df):

dayup = 1

for i in range(365):

if i % 7 in [6,0]:

dayup = dayup*(1 – 0.01)

else:

dayup = dayup*(1 + df)

return dayup

dayfactor = 0.01

while dayUP(dayfactor) < 37.78:

dayfactor += 0.001

print(“progress required on weekdays:{:.3f} “.format(dayfactor))

Beginners may be confused. Pay attention to the def-while construct. It’s a main construct in Python programming. def is used to state functions (a colon “:” is required), df is used to pass an argument, and whileis used to set the initial value. The progress of 0.001 is added to the initial value continuously until it reaches the cumulative progress of A.

 

The output is 0.019, that is, to rest on weekends, B needs to make twice the progress every day on weekdays. Why not just make the progress of 0.01 on weekends? You may think.

 

What if we make twice the progress on weekends, too? Then what is the output in a year? The output is pow(0.019,365)=962.89. Great progress, right?

 

It’s all up to you, but keep in mind the power of cumulative progress!

 

 

Note:

This example program is translated from a Chinese version that can be found at https://blog.csdn.net/weixin_43943977/article/details/102099476.