(13.)Write a function slope(x1, y1, x2, y2) that returns the slope of the line through the points (x1, y1) and (x2, y2). Be sure your implementation of slope can pass the following tests: def slope Cx1,41,x2, yzJ: return y2 -Y1 / x2-x1 test (slope (5, 3, 4, 2), 1.0) test(slope (1, 2, 3, 2), 0.0) test(slope (1, 2, 3, 3), 0.5) test (slope (2, 4, 1, 2), 2.0) 4- 3-1 こ 2-3 4-5 2-1 Then use a call to slope in a new function named intercept(x1, y1, x2, y2) that returns the y- intercept of the line through the points (x1, y1) and (x2, y2) test (intercept(1, 6, 3, 12), 3.0) test(intercept (6, 1, 1, 6), 7.0) test(intercept(4, 6, 12, 8), 5.0) def intercept (x 1,Y1,x?, y2); y= Slope (x1,1,x2,y2J*Ot return y

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
How do you do 13?? Explain each line of code too
10:13 PM Sun Feb 13
0 © 16% I
Back z
HowToThinkLikeAComputerScientist_LearningWithPython3_CSC_110.pdf
test (hypotenuse(24, 7), 25.0)
test (hypotenuse (9, 12), 15.0)
*(13.)Write a function slope(x1, y1, x2, y2) that returns the slope of the line through the points (x1,
y1) and (x2, y2). Be sure your implementation of slope can pass the following tests:
def slope (x1,41,x2, y zJ;
return y2 -Y1 / x2-x1
test(slope (5, 3, 4, 2), 1.0)
test(slope (1, 2, 3, 2), 0.0)
test(slope (1, 2, 3, 3), 0.5)
test(slope(2, 4, 1, 2), 2.0)
4ー
3-1
こ
2 - 3
: ).0
4-5
2-1
Then use a call to slope in a new function named intercept(x1, y1, x2, y2) that returns the y-
intercept of the line through the points (x1, y1) and (x2, y2)
test(intercept(1, 6, 3, 12), 3.0)
test(intercept (6, 1, 1, 6), 7.0)
test(intercept (4, 6, 12, 8), 5.0)
def intercept (x 1,Y1,x?, y2);
y= Slope (x1,v1,x2, y2J*Ot2
return
14. Write a function called is_even(n) that takes an integer as an argument and returns True if the
argument is an even number and False if it is odd.
Add your own tests to the test suite.
15. Now write the function is_odd(n) that returns True when n is odd and False otherwise. Include
unit tests for this function too.
Finally, modify it so that it uses a call to is_even to determine if its argument is an odd integer,
and ensure that its test still pass.
16. Write a function is_factor(f, n) that passes these tests:
Dashboard
Calendar
To Do
Notifications
M Inbox
Transcribed Image Text:10:13 PM Sun Feb 13 0 © 16% I Back z HowToThinkLikeAComputerScientist_LearningWithPython3_CSC_110.pdf test (hypotenuse(24, 7), 25.0) test (hypotenuse (9, 12), 15.0) *(13.)Write a function slope(x1, y1, x2, y2) that returns the slope of the line through the points (x1, y1) and (x2, y2). Be sure your implementation of slope can pass the following tests: def slope (x1,41,x2, y zJ; return y2 -Y1 / x2-x1 test(slope (5, 3, 4, 2), 1.0) test(slope (1, 2, 3, 2), 0.0) test(slope (1, 2, 3, 3), 0.5) test(slope(2, 4, 1, 2), 2.0) 4ー 3-1 こ 2 - 3 : ).0 4-5 2-1 Then use a call to slope in a new function named intercept(x1, y1, x2, y2) that returns the y- intercept of the line through the points (x1, y1) and (x2, y2) test(intercept(1, 6, 3, 12), 3.0) test(intercept (6, 1, 1, 6), 7.0) test(intercept (4, 6, 12, 8), 5.0) def intercept (x 1,Y1,x?, y2); y= Slope (x1,v1,x2, y2J*Ot2 return 14. Write a function called is_even(n) that takes an integer as an argument and returns True if the argument is an even number and False if it is odd. Add your own tests to the test suite. 15. Now write the function is_odd(n) that returns True when n is odd and False otherwise. Include unit tests for this function too. Finally, modify it so that it uses a call to is_even to determine if its argument is an odd integer, and ensure that its test still pass. 16. Write a function is_factor(f, n) that passes these tests: Dashboard Calendar To Do Notifications M Inbox
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY