Write a function is_three_digit_and_digit_sum_divisible_by_k(n, k) that returns True if n is a three-digit number (from 100 to 999) and the sum of its digits is divisible by k. In every other case it returns False.
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.
is_three_digit_and_digit_sum_divisible_by_k(145, 5) -> True
is_three_digit_and_digit_sum_divisible_by_k(123, 5) -> False
Implement this function:
def is_three_digit_and_digit_sum_divisible_by_k(n: int, k: 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, k.
Input
145
5
Output
True
Write a function `is_three_digit_and_digit_sum_divisible_by_k(n, k)` that returns `True` if `n` is a three-digit number (from 100 to 999) and the sum of its digits is divisible by `k`. In every other case it returns `False`. 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 ``` is_three_digit_and_digit_sum_divisible_by_k(145, 5) -> True is_three_digit_and_digit_sum_divisible_by_k(123, 5) -> False ``` ## Your task Implement this function: ```python def is_three_digit_and_digit_sum_divisible_by_k(n: int, k: 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`, `k`. ## Example **Input** ``` 145 5 ``` **Output** ``` True ``` The string `s` has at least 4 characters. Write a function `remove_second_and_second_last(s)` that returns `s` without its second character and without its second-last character. 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 ``` remove_second_and_second_last("abcdef") -> 'acdf' remove_second_and_second_last("abcd") -> 'ad' ``` ## Your task Implement this function: ```python def remove_second_and_second_last(s: 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: `s`. ## Example **Input** ``` "abcdef" ``` **Output** ``` 'acdf' ``` The keys of the dictionary `d` are integers, and `k1` and `k2` are two different keys of `d` whose values are numbers. Write a function `add_average_key_diff(d, k1, k2)` that adds a new entry to `d`. Its key is the average of `k1` and `k2` rounded with `round()`, and its value is the absolute difference of the values of `k1` and `k2`. The function changes `d` 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 ``` add_average_key_diff({2: 10, 8: 30}, 2, 8) -> {2: 10, 8: 30, 5: 20} add_average_key_diff({1: 5, 3: 2, 10: 7}, 1, 3) -> {1: 5, 3: 2, 10: 7, 2: 3} ``` ## Your task Implement this function: ```python def add_average_key_diff(d: dict, k1, k2) -> 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: `d`, `k1`, `k2`. ## Example **Input** ``` {2: 10, 8: 30} 2 8 ``` **Output** ``` {2: 10, 8: 30, 5: 20} ```