Write a function extract_border_elements(arr) that returns a list with the first and the last element of arr. If arr has only one element, the result has just that element. If arr is empty, the result is 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.
extract_border_elements([1, 2, 3, 4]) -> [1, 4]
extract_border_elements([5]) -> [5]
Implement this function:
def extract_border_elements(arr: 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: arr.
Input
[1, 2, 3, 4]
Output
[1, 4]
Write a function `extract_border_elements(arr)` that returns a list with the first and the last element of `arr`. If `arr` has only one element, the result has just that element. If `arr` is empty, the result is 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 ``` extract_border_elements([1, 2, 3, 4]) -> [1, 4] extract_border_elements([5]) -> [5] ``` ## Your task Implement this function: ```python def extract_border_elements(arr: 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: `arr`. ## Example **Input** ``` [1, 2, 3, 4] ``` **Output** ``` [1, 4] ``` The strings `time1` and `time2` are times of one day in the 24 hour format `"HH:MM"`. Write a function `absolute_time_difference(time1, time2)` that returns the difference between them, whichever is earlier, as a string in the format `"HH:MM"`, with two digits for the hours and two digits for the minutes. 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 ``` absolute_time_difference("14:30", "06:45") -> '07:45' absolute_time_difference("02:30", "03:10") -> '00:40' ``` ## Your task Implement this function: ```python def absolute_time_difference(time1: str, time2: str) -> str: ``` 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: `time1`, `time2`. ## Example **Input** ``` "14:30" "06:45" ``` **Output** ``` '07:45' ``` The dictionary `accounts` maps account numbers to their balances. Write a function `transfer_amount(accounts, sender, recipient, amount)` that moves `amount` from the account `sender` to the account `recipient`. The transfer is made only if both accounts are in `accounts`, `amount` is not negative, and the balance of `sender` is at least `amount`. Otherwise `accounts` is left as it is. The function changes `accounts` itself and returns nothing. 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 ``` transfer_amount({"12345": 500, "67890": 1000, "98764": 1500}, "12345", "67890", 1000) -> {'12345': 500, '67890': 1000, '98764': 1500} transfer_amount({"12345": 500, "67890": 1000, "98764": 1500}, "12345", "67890", 400) -> {'12345': 100, '67890': 1400, '98764': 1500} ``` ## Your task Implement this function: ```python def transfer_amount(accounts: dict, sender: str, recipient: str, amount: int) -> None: ``` Write the function only — the arguments are read for you and the argument you change is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `accounts`, `sender`, `recipient`, `amount`. ## Example **Input** ``` {"12345": 500, "67890": 1000, "98764": 1500} "12345" "67890" 1000 ``` **Output** ``` {'12345': 500, '67890': 1000, '98764': 1500} ```