code: def interp(mapping, x):
      
      mapping = sorted(mapping)
      if len(mapping) == 1:
          xa, ya = mapping[0]
          if xa == x:
              return ya
          return x
      for (xa, ya), (xb, yb) in zip(mapping[:-1], mapping[1:]):
          if xa <= x <= xb:
              return ya + float(x - xa) / (xb - xa) * (yb - ya)
      return x
docs: Compute the piecewise linear interpolation given by mapping for input x.
  
      >>> interp(((1, 1), (2, 4)), 1.5)
      2.5