Define a function named get_sorted_in_parallel (tuples1, tuples2) which takes two tuples of integers as parameters. The tuples have the same length and their elements are related, i.e. the element at each index of the second parameter tuple corresponds to the element at the same index in the first parameter tuple, e.g. the element at index 1 in the first tuple corresponds to the element at index 1 in the second tuple. The function sorts the first parameter tuple, keeping the elements of the second parameter tuple in the order corresponding to the sorted first parameter tuple. The function returns a tuple made up of the sorted first parameter tuple and the new corresponding second tuple. For example, the following code fragment: tuple1 = (4, 1, 3) tuple2 (9, 8, 6) tuple3, tuple4 = get_sorted_in_parallel (tuplel, tuple2) print(tuple1, "-", tuple2) print (tuple3, "-", tuple4) prints: (4, 1, 3) (9, 8, 6) (1, 3, 4) (8, 6, 9) 4 and 9 are connected, 1 and 8 connected, 3 and 6 are connected. The function sorts the first tuple, so 1 is the first element in the first tuple, so 8 will be the first element in the second tuple. 3 is the second element in the first tuple, so 6 will be the second element in the second tuple. 4 is the last element in the first tuple, so 9 will be the last element in the second tuple. Note: you can assume that the tuple1 parameter contains unique elements (i.e. no duplicates). For example: Test Result tuple1 = (5, 6, 2, 1, 3) (5, 6, 2, 1, 3) (1, 2, 3, 5, 6) (3, 8, 9, 6, 7) (6, 9, 7, 3, 8) tuple2 = (3, 8, 9, 6, 7) tuple3, tuple4 = get_sorted_in_parallel(tuple1, tuple2) print (tuple1, "-", tuple2) print (tuple3, "-", tuple4) tuple1 = (3, 8, 4, 9, 1, 2, 7) (3, 8, 4, 9, 1, 2, 7) - (43, 24, 76, 12, 9, 23, 14) tuple2 = (43, 24, 76, 12, 9, 23, 14) (1, 2, 3, 4, 7, 8, 9) - (9, 23, 43, 76, 14, 24, 12) tuple3, tuple4 = get_sorted_in_parallel(tuple1, tuple2) print (tuple1, "-", tuple2) print (tuple3, "-", tuple4)

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

Pyhton code please help, indentation would be greatly appreciated 

Define a function named get_sorted_in_parallel(tuples1, tuples2) which takes two tuples of integers as parameters.
The tuples have the same length and their elements are related, i.e. the element at each index of the second parameter tuple
corresponds to the element at the same index in the first parameter tuple, e.g. the element at index 1 in the first tuple
corresponds to the element at index 1 in the second tuple. The function sorts the first parameter tuple, keeping the elements of
the second parameter tuple in the order corresponding to the sorted first parameter tuple. The function returns a tuple made
up of the sorted first parameter tuple and the new corresponding second tuple. For example, the following code fragment:
tuple1 = (4, 1, 3)
tuple2 = (9, 8, 6)
get_sorted_in_parallel(tuplel, tuple2)
tuple3, tuple4 =
print (tuplel, "-", tuple2)
print (tuple3, "-", tuple4)
prints:
(4, 1, 3)
(9, 8, 6)
(8, 6, 9)
(1, 3, 4)
4 and 9 are connected, 1 and 8 are connected, 3 and 6 are connected. The function sorts the first tuple, so 1 is the first element
in the first tuple, so 8 will be the first element in the second tuple. 3 is the second element in the first tuple, so 6 will be the
second element in the second tuple. 4 is the last element in the first tuple, so 9 will be the last element in the second tuple.
Note: you can assume that the tuple1 parameter contains unique elements (i.e. no duplicates).
For example:
Test
Result
tuple1
=
(5, 6, 2, 1, 3)
(5, 6, 2, 1, 3)
(1, 2, 3, 5, 6)
(3, 8, 9, 6, 7)
(6, 9, 7, 3, 8)
tuple2 = (3, 8, 9, 6, 7)
=
get_sorted_in_parallel(tuplel, tuple2)
tuple3, tuple4
print (tuple1, "-", tuple2)
print (tuple3, "-", tuple4)
tuple1
=
(3, 8, 4, 9, 1, 2, 7)
(3, 8, 4, 9, 1, 2, 7)
(43, 24, 76, 12, 9, 23, 14)
tuple2 = (43, 24, 76, 12, 9, 23, 14)
(1, 2, 3, 4, 7, 8, 9)
-
(9, 23, 43, 76, 14, 24, 12)
tuple3, tuple4 =
get_sorted_in_parallel(tuplel, tuple2)
print (tuple1, "-", tuple2)
print (tuple3, "-", tuple4)
Transcribed Image Text:Define a function named get_sorted_in_parallel(tuples1, tuples2) which takes two tuples of integers as parameters. The tuples have the same length and their elements are related, i.e. the element at each index of the second parameter tuple corresponds to the element at the same index in the first parameter tuple, e.g. the element at index 1 in the first tuple corresponds to the element at index 1 in the second tuple. The function sorts the first parameter tuple, keeping the elements of the second parameter tuple in the order corresponding to the sorted first parameter tuple. The function returns a tuple made up of the sorted first parameter tuple and the new corresponding second tuple. For example, the following code fragment: tuple1 = (4, 1, 3) tuple2 = (9, 8, 6) get_sorted_in_parallel(tuplel, tuple2) tuple3, tuple4 = print (tuplel, "-", tuple2) print (tuple3, "-", tuple4) prints: (4, 1, 3) (9, 8, 6) (8, 6, 9) (1, 3, 4) 4 and 9 are connected, 1 and 8 are connected, 3 and 6 are connected. The function sorts the first tuple, so 1 is the first element in the first tuple, so 8 will be the first element in the second tuple. 3 is the second element in the first tuple, so 6 will be the second element in the second tuple. 4 is the last element in the first tuple, so 9 will be the last element in the second tuple. Note: you can assume that the tuple1 parameter contains unique elements (i.e. no duplicates). For example: Test Result tuple1 = (5, 6, 2, 1, 3) (5, 6, 2, 1, 3) (1, 2, 3, 5, 6) (3, 8, 9, 6, 7) (6, 9, 7, 3, 8) tuple2 = (3, 8, 9, 6, 7) = get_sorted_in_parallel(tuplel, tuple2) tuple3, tuple4 print (tuple1, "-", tuple2) print (tuple3, "-", tuple4) tuple1 = (3, 8, 4, 9, 1, 2, 7) (3, 8, 4, 9, 1, 2, 7) (43, 24, 76, 12, 9, 23, 14) tuple2 = (43, 24, 76, 12, 9, 23, 14) (1, 2, 3, 4, 7, 8, 9) - (9, 23, 43, 76, 14, 24, 12) tuple3, tuple4 = get_sorted_in_parallel(tuplel, tuple2) print (tuple1, "-", tuple2) print (tuple3, "-", tuple4)
Expert Solution
steps

Step by step

Solved in 2 steps with 1 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