Answer:
lst = [11, 603, 99, 7, 582, 1];
print("The index of the middle element: " + str(int(len(lst)/2)))
print("The middle element: " + str(lst[int(len(lst)/2)]))
lst.sort()
sorted_lst = lst.reverse()
print("The list in descending order: " + str(lst))
first_number = lst.pop(0)
lst.append(first_number)
print("New lst: "+ str(lst))
Explanation:
- Initialize a list
- Find the middle index, int(len(lst)/2)
- Find the middle element, lst[int(len(lst)/2)]
- Sort the list in descending order (First sort the list in ascending order than reverse it)
- Get the first element using <em>pop</em> method, and append it to the end using <em>append</em> method
- - - - -
a) 0 == 1 == 2 --> Always evaluates false
b) 2 + (3 == 4) + 5 == 7 --> Evaluates true
c) 1 < -1 == 3 > 4 --> Always evaluates false