Write a function first_and_last(s) that returns a string of exactly two characters: the first character of s followed by the last character of s. The string s has at least one character. If s has only one character, that character is both the first and the last, so it comes twice.
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.
first_and_last("mango") -> 'mo'
first_and_last("Chennai") -> 'Ci'
Implement this function:
def first_and_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.
Input
"mango"
Output
'mo'

Write a function `first_and_last(s)` that returns a string of exactly two characters: the first character of `s` followed by the last character of `s`. The string `s` has at least one character. If `s` has only one character, that character is both the first and the last, so it comes twice. 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 ``` first_and_last("mango") -> 'mo' first_and_last("Chennai") -> 'Ci' ``` ## Your task Implement this function: ```python def first_and_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** ``` "mango" ``` **Output** ``` 'mo' ``` Write a function `last_k(s, k)` that returns the last `k` characters of the string `s`, in the same order as they are in `s`. You can be sure that `k` is at least 1 and at most the length of `s`. If `k` is equal to the length of `s`, the answer is the whole string. 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 ``` last_k("9876543210", 4) -> '3210' last_k("hostel", 1) -> 'l' ``` ## Your task Implement this function: ```python def last_k(s: str, k: int) -> 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`, `k`. ## Example **Input** ``` "9876543210" 4 ``` **Output** ``` '3210' ``` Write a function `every_second(s)` that returns a new string made of the characters of `s` at the indices 0, 2, 4 and so on. In other words, keep the first character, skip the next one, keep the next one, and continue like this till the end. The string `s` has at least one character. A space is a character like any other. 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 ``` every_second("abcdef") -> 'ace' every_second("python") -> 'pto' ``` ## Your task Implement this function: ```python def every_second(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** ``` 'ace' ```