Write a function get_element_at_circular_index(lst, idx) that returns the element of the non-empty list lst at the index idx, where the indexing is circular: after the last element it goes on from the first element again, and a negative index counts back from the end in the same way. For a list of 3 elements, index 3 is the first element, index 4 is the second element, and index -1 is the last one.
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.
get_element_at_circular_index([1, 2, 3], 4) -> 2
get_element_at_circular_index([10, 20, 30, 40], -1) -> 40
Implement this function:
def get_element_at_circular_index(lst: list, idx: 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, idx.
Input
[1, 2, 3]
4
Output
2
Write a function `get_element_at_circular_index(lst, idx)` that returns the element of the non-empty list `lst` at the index `idx`, where the indexing is circular: after the last element it goes on from the first element again, and a negative index counts back from the end in the same way. For a list of 3 elements, index 3 is the first element, index 4 is the second element, and index -1 is the last one. 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 ``` get_element_at_circular_index([1, 2, 3], 4) -> 2 get_element_at_circular_index([10, 20, 30, 40], -1) -> 40 ``` ## Your task Implement this function: ```python def get_element_at_circular_index(lst: list, idx: 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`, `idx`. ## Example **Input** ``` [1, 2, 3] 4 ``` **Output** ``` 2 ``` Write a function `signed_abs_diff_of_middle_digits(n)` that looks at the digits of `n` (without its sign). If there is an odd number of digits, take the single middle digit. If there is an even number of digits, take the absolute difference of the two middle digits. The function returns that number, with a minus sign if `n` is negative. 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 ``` signed_abs_diff_of_middle_digits(12345) -> 3 signed_abs_diff_of_middle_digits(-987) -> -8 ``` ## Your task Implement this function: ```python def signed_abs_diff_of_middle_digits(n: int) -> 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: `n`. ## Example **Input** ``` 12345 ``` **Output** ``` 3 ``` Write a function is_decreasing_number(n: int) -> bool that checks if a given 4-digit number is decreasing, meaning each digit is strictly less than the digit before it (from left to right). The function should return True if the number meets the criteria and False otherwise. ### Constraints The input number will be a 4-digit number, which means it will be in the range of 1000 to 9999. ### Example ``` >>> is_decreasing_number(4321) True >>> is_decreasing_number(4312) False >>> is_decreasing_number(9876) True >>> is_decreasing_number(1111) False >>> is_decreasing_number(3210) True ``` ## Your task Implement this function: ```python def is_decreasing_number(n: int) -> bool: ``` 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: `n`. ## Example **Input** ``` 4321 ``` **Output** ``` True ```