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

 

gaurav1780@gmail.com 01_variables_and_operators > get_x
prev  |  next  |  chance

Define a function that when passed the coordinates of two points (x1, y1) and (x2, y2) through which a line passes and another value (y3), returns the x-coordinate of the point on the line when y = y3. You may assume the line is not vertical (because then we'll need conditions). Just like the perimeter function (https://codingbat.com/prob/p244438), the complexity of this question is in the research and analysis, not the implementation. You may assume the x-coordinate corresponding to y3 is an integer. That is, the line passes through (x3, y3) where x3 and y3 are both integers.


get_x(2, 6, 4, 12, 30) → 10
get_x(5, 4, 20, 5, 6) → 35
get_x(2, 6, 4, 12, -12) → -4

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

def get_x(x1, y1, x2, y2, y3):

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

Post-solution available

Copyright Nick Parlante 2017 - privacy