Please write it in Python Write a delete function that takes as an argument a list l and an elem element and returns the list obtained from l by deleting all occurrences of elem. Example: delete([4, 7, 12, 4, 4, 0, 4, 5], 4) return => [7, 12, 0, 5]. Write a function insere_milieu that takes as an argument a list l and an element elem and returns the list obtained from l by adding elem "in the middle" of l, that is: If the length of l is even, the item is added once, in the middle of the list. If the length of l is odd: the element is added on either side of the central element. Example: insere_milieu([4, 7, 12, 3], 0) return => [4, 7, 0, 12, 3] and insere_milieu([9, 3, 5, 6, 2], 1) return => [9, 3, 1, 5, 1, 6, 2]. Write a cutting function that takes as an argument a list of numbers l and a threshold number and returns two lists: the first is obtained from l keeping only the numbers below or equal to the threshold; the second is obtained from l keeping only the numbers strictly above the threshold. Example: cut([14, 27, 12, 0, 40, 34, 20, 11], 20) has the return value [14, 12, 0, 20, 11] and [27, 40, 34].
Please write it in Python Write a delete function that takes as an argument a list l and an elem element and returns the list obtained from l by deleting all occurrences of elem. Example: delete([4, 7, 12, 4, 4, 0, 4, 5], 4) return => [7, 12, 0, 5]. Write a function insere_milieu that takes as an argument a list l and an element elem and returns the list obtained from l by adding elem "in the middle" of l, that is: If the length of l is even, the item is added once, in the middle of the list. If the length of l is odd: the element is added on either side of the central element. Example: insere_milieu([4, 7, 12, 3], 0) return => [4, 7, 0, 12, 3] and insere_milieu([9, 3, 5, 6, 2], 1) return => [9, 3, 1, 5, 1, 6, 2]. Write a cutting function that takes as an argument a list of numbers l and a threshold number and returns two lists: the first is obtained from l keeping only the numbers below or equal to the threshold; the second is obtained from l keeping only the numbers strictly above the threshold. Example: cut([14, 27, 12, 0, 40, 34, 20, 11], 20) has the return value [14, 12, 0, 20, 11] and [27, 40, 34].
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
Related questions
Question
Please write it in Python
- Write a delete function that takes as an argument a list l and an elem element and returns the list obtained from l by deleting all occurrences of elem.
Example: delete([4, 7, 12, 4, 4, 0, 4, 5], 4) return => [7, 12, 0, 5].
- Write a function insere_milieu that takes as an argument a list l and an element elem and returns the list obtained from l by adding elem "in the middle" of l, that is:
- If the length of l is even, the item is added once, in the middle of the list.
- If the length of l is odd: the element is added on either side of the central element.
Example: insere_milieu([4, 7, 12, 3], 0) return => [4, 7, 0, 12, 3] and
insere_milieu([9, 3, 5, 6, 2], 1) return => [9, 3, 1, 5, 1, 6, 2].
- Write a cutting function that takes as an argument a list of numbers l and a threshold number and returns two lists: the first is obtained from l keeping only the numbers below or equal to the threshold; the second is obtained from l keeping only the numbers strictly above the threshold.
Example: cut([14, 27, 12, 0, 40, 34, 20, 11], 20) has the return value [14, 12, 0, 20, 11] and [27, 40, 34].
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning