Python Function to Calculate Slope Percentage Between Two Points
def calculate_slope(x1, y1, x2, y2): 'Calculate the slope between two points (x1, y1) and (x2, y2)' rise = y2 - y1 run = x2 - x1 slope = (rise/run)*100 return slope
Example usage
slope = calculate_slope(0, 0, 100, 5) print('The slope between (0, 0) and (100, 5) is:', slope, '%')
原文地址: https://www.cveoy.top/t/topic/lXDn 著作权归作者所有。请勿转载和采集!