Write a function near_multiple(n, k) that returns the multiple of the positive integer k which is nearest to the non-negative integer n. If n is exactly in the middle of two multiples, return the larger 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.
near_multiple(13, 5) -> 15
near_multiple(12, 5) -> 10
Implement this function:
def near_multiple(n: int, k: 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, k.
Input
13
5
Output
15
Write a function `near_multiple(n, k)` that returns the multiple of the positive integer `k` which is nearest to the non-negative integer `n`. If `n` is exactly in the middle of two multiples, return the larger 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 ``` near_multiple(13, 5) -> 15 near_multiple(12, 5) -> 10 ``` ## Your task Implement this function: ```python def near_multiple(n: int, k: 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`, `k`. ## Example **Input** ``` 13 5 ``` **Output** ``` 15 ``` The string `s` has at least 2 lowercase letters. Write a function `encode_by_shifting_ends(s)` that returns `s` with its first letter replaced by the next letter of the alphabet and its last letter replaced by the previous letter of the alphabet. The letters in the middle stay as they are. There are two exceptions: a first letter `z` stays `z`, and a last letter `a` stays `a`. 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 ``` encode_by_shifting_ends("abc") -> 'bbb' encode_by_shifting_ends("hello") -> 'ielln' ``` ## Your task Implement this function: ```python def encode_by_shifting_ends(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** ``` "abc" ``` **Output** ``` 'bbb' ``` Write a function repeat_second_half(t) that takes a tuple t and returns a new tuple where the second half of the original tuple is repeated after the first half. If the tuple has an odd number of elements, the middle element should be included in the first half. ### Constraints The input tuple will contain at least two elements.\ The elements in the tuple can be of any type (integers, strings, etc.). 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 ``` >>> repeat_second_half((1, 2, 3, 4, 5)) (1, 2, 3, 4, 5, 4, 5) >>> repeat_second_half((10, 20, 30, 40)) (10, 20, 30, 40, 30, 40) >>> repeat_second_half(('a', 'b', 'c', 'd', 'e', 'f')) ('a', 'b', 'c', 'd', 'e', 'f', 'd', 'e', 'f') >>> repeat_second_half((1, 2, 3)) (1, 2, 3, 3) ``` ## Your task Implement this function: ```python def repeat_second_half(t: tuple) -> tuple: ``` 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: `t`. ## Example **Input** ``` (1, 2, 3, 4, 5) ``` **Output** ``` (1, 2, 3, 4, 5, 4, 5) ```