Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question
Exercise 4A Write functions to perform the following tasks efficiently. Do not change the function names
in the template file, and do not import any packages besides those already indicated in the template.
(1) Take x and return 2x³
- X.
(2) Take two inputs x and y and return their product and the absolute value of their difference, in that
order. E.g. inputs 3, 4 should return 12, 1.
(3) The geometric mean of n numbers is the nth root of their product. The mid-range is the ordinary
(arithmetic) mean of the maximum and minimum elements. Write a function which takes a list of
numbers as input and returns True if the geometric mean is less than or equal to the midrange, and False
if the geometric mean is greater than the midrange. For example, the input [3,8,9] should return True
and [3,6,7,5] should return False.
(4) Take an integer n and returns a list of the first n of the Padovan sequence Pn. (This is a variant of
the Fibonacci numbers, defined by P₁ = P2 = P3 = = 1, and pn = Pn−2+ Pn-3 for n ≥ 4.)
(5) Take a pair r≥ 0 and representing a point's polar coordinates and return a pair x, y representing
its Cartesian coordinates.
0
(6) Take a pair x, y representing a point's Cartesian coordinates and return a pair r, representing its
polar coordinates, where = [0, 2π). Check that your function works for (x, y) in all quadrants.
expand button
Transcribed Image Text:Exercise 4A Write functions to perform the following tasks efficiently. Do not change the function names in the template file, and do not import any packages besides those already indicated in the template. (1) Take x and return 2x³ - X. (2) Take two inputs x and y and return their product and the absolute value of their difference, in that order. E.g. inputs 3, 4 should return 12, 1. (3) The geometric mean of n numbers is the nth root of their product. The mid-range is the ordinary (arithmetic) mean of the maximum and minimum elements. Write a function which takes a list of numbers as input and returns True if the geometric mean is less than or equal to the midrange, and False if the geometric mean is greater than the midrange. For example, the input [3,8,9] should return True and [3,6,7,5] should return False. (4) Take an integer n and returns a list of the first n of the Padovan sequence Pn. (This is a variant of the Fibonacci numbers, defined by P₁ = P2 = P3 = = 1, and pn = Pn−2+ Pn-3 for n ≥ 4.) (5) Take a pair r≥ 0 and representing a point's polar coordinates and return a pair x, y representing its Cartesian coordinates. 0 (6) Take a pair x, y representing a point's Cartesian coordinates and return a pair r, representing its polar coordinates, where = [0, 2π). Check that your function works for (x, y) in all quadrants.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY