Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a function called (rtrnslope). This function will take 4 integers and return a float. each float will be between 0 and 10. You

• Create a function called (rtrnslope). This function will take 4 integers and return a float.

 • each float will be between 0 and 10. You will do input validation outside of the function.

 • Inside the function, the first two numbers are the x and y values of a point on a Cartesian map. Note: You can review Cartesian maps on Khan Academy, if you don't remember! 

• The last two numbers are the x and y values of a second point. 

• Your function should return the calculate slope of these two points.

 • Call your rtrnslope function inside your challenge4.py script. Use hard-coded values to test. For example, rtrn_slope(1, 1, 3, 3) should return a slope of 1.0.

 • Once your function is returning the correct slope, use input() to get these values from the user. Remember to validate the user input!. Values outside of the acceptable range should cause an error. 

• Finally, put the second input() statement inside a while loop. 

image

Sample Output Please note I omitted the input validation step from this sample, however your code should have it! Enter the starting X value: 1 Enter the next Y value: 1 Enter the new X value: 3 Enter the new Y value: 3 Slope is: 1.0 Enter the new X value: 3 Enter the new Y value: 3 Slope is: 0.0 Enter the new X value: 5 Enter the new Y value: 4 Slope is: 0.5 Enter the new X value: 0 Enter the new Y value: 1 Slope is: 0.6 Enter the new X value: 3 Enter the new Y value: 0 Slope is: -0.3333333333333333

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Elements Of Chemical Reaction Engineering

Authors: H. Fogler

6th Edition

013548622X, 978-0135486221

More Books

Students also viewed these Programming questions