How do I get the slope?

I'm "new" to programming,
I want to see a lot of data without having to change the screen
I am creating a data field (12 data are currently available) and I need to set the slope. How do I get that data? some example?
  • You are going to have to calculate it. Basically it's rise/run - or vertical distance divided by horizontal distance. The calculation is straight forward, but plenty of little issues to think about. You can't get instantaneous slope as there is no distance or vertical. You need to decide if you want it over the past time or distance interval. Using a time interval, you have to deal with zero distance. Should be obvious, but you need to make sure the vertical distance is in the same units as horizontal distance. Probably use meters. The longer the interval you use, the more accurate the numbers will be, but use too long an interval and it will smooth out the slope too much.

    (end elevation - start elevation) / (end distance - start distance)