Question: Question-3: Solve using Python Code . Write a function named weird_sort() that will take a list of numbers as an argument and then RETURN a

Question-3:

Solve using Python Code .

Write a function named weird_sort() that will take a list of numbers as an

argument and then RETURN a new list that will follow the format given

below.

Returned list format: [Largest, Smallest, Second largest, Second

smallest,...so on...]

Then print the returned list in the function call. You can assume the

length of the given list will always be even, there will be no duplicate

values, and the values will be in range(0,101).

================================================

Function Call 01:

weird_sort([9, 3, 5, 7, 16, 20])

Sample Output 01:

[20, 3, 16, 5, 9, 7]

Explanation 01:

Largest value is 20 and the smallest value is 3. That's why in case of

output, the values of the first two indices are 20 and 3. Similarly the

second largest value and second smallest values are 16 and 5 respectively

which are the values of the following two indices.

================================================

Function Call 02:

weird_sort([10,20,30,40,50,60])

Sample Output 02:

[60, 10, 50, 20, 40, 30]

Explanation 02:

Largest value is 60 and the smallest value is 10. That's why in case of

output, the values of the first two indices are 60 and 10. Similarly the

second largest value and second smallest values are 50 and 20 respectively

which are the values of the following two indices.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!