id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

rmueller@lasacs.com final2020period1 > interpolate
prev  |  next  |  chance

If the two known points are given by the coordinates (x0,y0) and (x1,y1), the linear interpolant is the straight line between these points. For a given x, you can find the interpolated value y, by using y = y0 + (x-x0)*((y1-y0)/(x1-x0)). Given (x0,y0), (x1,y1), and x, return y (rounded to two decimal places).


interpolate(1, 1, 3, 3, 2) → 2.0
interpolate(1, 1, 2, 2, 1.5) → 1.5
interpolate(2, 3, 6, 11, 4) → 7.0

...Save, Compile, Run (ctrl-enter)

def interpolate(x0,y0,x1,y1,x):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 100

Copyright Nick Parlante 2017 - privacy