Question
Question-3:Solve Using Python Programme : Write a function named weird_sort() that will take a list of numbers as an argument and then RETURN a new
Question-3:Solve Using Python Programme :
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started