For example:If the list PLACES contains [''DELHI'', ''LONDON'', ''PARIS'', ''NEW YORK'', ''DUBAI'']The following should get displayedLONDONNEW YORK
11 questions · timed · auto-graded
For example:If the list PLACES contains [''DELHI'', ''LONDON'', ''PARIS'', ''NEW YORK'', ''DUBAI'']The following should get displayedLONDONNEW YORK
For example,If the SCORES contain [200,456,300,100,234,678]The sum should be displayed as 600.
Example:
If List X contains 7 integers is as follows:
| X[0] | X[1] | X[2] | X[3] | X[4] | X[5] | X[6] |
| 4 | 8 | 7 | 5 | 6 | 2 | 10 |
After executing the function, the array content should be displayed as follows:
• To print sum of all element of the list• To find maximum element of the list• To find minimum element of the list• To find the length of the list• To sort the list in ascending order• To sort the list in descending order
In this case, while entering the list, we have to enter the
list in square bracket.
Input:
Enter the list[1,2,3,4]
Data Structure 97
Output:
[1, 2, 3, 4]
<class ‘list’>
Case 2:
In this case, we can enter the list elements segregated
with space. i.e
Input:
Enter the list : 1 2 3 4 5
Output:
[1, 2, 3, 4, 5]
<class ‘list’>
Case 3:
In this case, we can enter the list of items one by one
and add the element to the list using the append method.
i.e.
Input:
Enter a number: 1
Enter more data(y/n)? y
Enter a number: 4
Enter more data(y/n)? n
Output:
[1, 4]
<class ‘list’>
[22, 54, 12, 90, 55, 78]Write the passes of selection sort for sorting the list in ascending order till the 3rd iteration.
79 19 43 52 3 95
Write the passes of bubble sort for sorting the list in ascending order till the 3rd iteration.
Different types of sorting methods are Bubble sort, Selection Sort, Insertion Sort, Quick Sort, Bucket Sort.