Write a function drop_ends(lst) that returns a new list with all the elements of lst except the first one and the last one, in the same order. If lst has fewer than 3 elements, return an empty list. The list lst itself must not be changed.
NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition.
drop_ends([1, 2, 3, 4, 5]) -> [2, 3, 4]
drop_ends([10, 20]) -> []
Implement this function:
def drop_ends(lst: list) -> list:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: lst.
Input
[1, 2, 3, 4, 5]
Output
[2, 3, 4]

Write a function `drop_ends(lst)` that returns a new list with all the elements of `lst` except the first one and the last one, in the same order. If `lst` has fewer than 3 elements, return an empty list. The list `lst` itself must not be changed. NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition. ### Example ``` drop_ends([1, 2, 3, 4, 5]) -> [2, 3, 4] drop_ends([10, 20]) -> [] ``` ## Your task Implement this function: ```python def drop_ends(lst: list) -> list: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `lst`. ## Example **Input** ``` [1, 2, 3, 4, 5] ``` **Output** ``` [2, 3, 4] ``` Write a function `squares_of_evens(nums)` that takes a list of integers and returns a new list with the square of every even number of `nums`, in the same order as in `nums`. Odd numbers are left out. 0 is even, and negative numbers can be even too. If there is no even number, return an empty list. NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition. ### Example ``` squares_of_evens([1, 2, 3, 4]) -> [4, 16] squares_of_evens([-2, 5, 0]) -> [4, 0] ``` ## Your task Implement this function: ```python def squares_of_evens(nums: list) -> list: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `nums`. ## Example **Input** ``` [1, 2, 3, 4] ``` **Output** ``` [4, 16] ``` Write a function `first_position(lst, x)` that returns the index of the first element of `lst` that is equal to `x`. Indexes start at 0. If no element of `lst` is equal to `x` (this includes the case of an empty list), return -1. NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition. ### Example ``` first_position([5, 3, 7, 3], 3) -> 1 first_position([5, 3, 7], 9) -> -1 ``` ## Your task Implement this function: ```python def first_position(lst: list, x) -> int: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `lst`, `x`. ## Example **Input** ``` [5, 3, 7, 3] 3 ``` **Output** ``` 1 ```