Write a function same_ends(n) that returns True if the first digit and the last digit of the integer n are the same, and False otherwise. The sign of n is ignored, so -4514 is treated like 4514. A number with a single digit, such as 5 or 0, has the same first and last digit, so the answer is True.
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.
same_ends(7337) -> True
same_ends(1234) -> False
Implement this function:
def same_ends(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.
Input
7337
Output
True

Write a function `same_ends(n)` that returns `True` if the first digit and the last digit of the integer `n` are the same, and `False` otherwise. The sign of `n` is ignored, so `-4514` is treated like `4514`. A number with a single digit, such as `5` or `0`, has the same first and last digit, so the answer is `True`. 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 ``` same_ends(7337) -> True same_ends(1234) -> False ``` ## Your task Implement this function: ```python def same_ends(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** ``` 7337 ``` **Output** ``` True ``` Write a function `swap_halves(s)` that returns a new string in which the first half and the second half of `s` have changed places. If the length of `s` is even, the two halves have the same length: `"abcd"` becomes `"cdab"`. If the length is odd, the middle character stays in the middle and the parts before it and after it change places: `"abcde"` becomes `"decab"`. A string with one character, or an empty string, is returned as it is. 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 ``` swap_halves("abcd") -> 'cdab' swap_halves("abcde") -> 'decab' ``` ## Your task Implement this function: ```python def swap_halves(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** ``` "abcd" ``` **Output** ``` 'cdab' ``` Write a function `count_common(a, b)` that returns how many different values are present in both lists `a` and `b`. A value is counted only once, even if it comes many times in a list. If no value is in both lists, or if a list is empty, return `0`. 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 ``` count_common([1, 2, 2, 3], [2, 3, 3, 4]) -> 2 count_common(["a", "b"], ["c"]) -> 0 ``` ## Your task Implement this function: ```python def count_common(a: list, b: list) -> 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: `a`, `b`. ## Example **Input** ``` [1, 2, 2, 3] [2, 3, 3, 4] ``` **Output** ``` 2 ```