check percentage change python code example

Example: percentage change python

# How to see percent change using python 
# Using python==3.8.6 

example_nums = [8, 16, 4, -6, 7, 84] 

def percent_change(start_point, end_point):
  # This is going to be a little long but bare with me here
  return ((float(end_point) - start_point) / abs(start_point)) * 100.00 

for numbers in example_nums:
  percentage = percent_change(example_nums[0], numbers) 
  print(str(numbers) + ' -- ' + str(percentage))
 
# The output should look like:
#8 -- 0.0 
#16 -- 100.0 
#4 -- -50.0 
#-6 -- -175.0
#7 -- -12.5 
#84 -- 950.0