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

 

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

Equation of a line is given as y = mx + b, where m is the gradient (angle) and b is the y-intercept at x=0. Define a function that given two points through which line passes, returns the gradient of the line. Return null if it is a vertical line (hence, the return type Double) If you don't have the required math knowledge, refer to this page: See this to further understand this: https://www.mathsisfun.com/equation_of_line.html


garadient(10, 5, 7, 4) → 0.3333333333333333
garadient(5, 8, -1, 20) → -2.0
garadient(10, 0, 10, 20) → None

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

def garadient(x1, y1, x2, y2):

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: 1 Post-solution available

Copyright Nick Parlante 2017 - privacy