Method of Group averages using python

Since my 12th grade, I have been fascinated by mathematics, but the only downside to my intuition is that I can not relate these advanced mathematics with the previous knowledge I acquired up to my 10th grade.

The same limitation persisted until my graduation, but when I began to learn python, I was introduced to the details on the application of these mathematical concepts that helped me gradually develop mathematical intuition.

Among the different concepts I studied in mathematics, I would like to show the python code that was used to fit the straight line for a given data point in a dataset with the method called “Method of Group averages”

If you are trying to learn the same concept then you can use my code to get a better intuition.