Question: PYTHON CLASS Will like if you answer please. (10 pts) Write a list comprehension that creates a list of all numbers from 1 to 999
PYTHON CLASS
Will like if you answer please.
(10 pts) Write a list comprehension that creates a list of all numbers from 1 to 999 for which the digits sum to 15. [ ] # Put your code here. (18 pts) Write function named sort() that will return a sorted copy of a list. You must write your own sorting code. A simple sorting algorithm is: (1) find the smallest element in a list, (2) append that element to a second list, (3) repeat until done. Your sort function should take two arguments. The first argument is the list to sort. The second argument is the comparator function (use parameter name of cmp ) to use to compare two items from the list. The comparator function will accept two elements a and b and will return -1 if a b. Note that your function must not modify the original list. [ ] # Put your sort function here. [5 pts] In the cell below, put your comparator functions. You will need to implement two different comparator functions. The less than() comparator will sort in ascending order. The greater_than ( ) comparator will result in a descending order sort. [ ] # Put your less_than() and greater_than() function here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
