Write a function double_ends(l) that takes a list l (with at least two elements) and returns a new list where the first and last elements of l are duplicated at the beginning and end of the list, respectively.
The new list should have:
The first element of the original list inserted once at the beginning The last element of the original list inserted once at the end
You must not modify the original list.
The input list will contain at least two elements
The list can contain elements 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.
>>> double_ends([10, 20, 30])
[10, 10, 20, 30, 30]
>>> double_ends(['a', 'b', 'c'])
['a', 'a', 'b', 'c', 'c']
>>> double_ends([1, 2])
[1, 1, 2, 2]
>>> double_ends([5, 6, 7, 8])
[5, 5, 6, 7, 8, 8]
Implement this function:
def double_ends(l: list) -> list:
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: l.
Input
[10, 20, 30]
Output
[10, 10, 20, 30, 30]
Write a function double_ends(l) that takes a list l (with at least two elements) and returns a new list where the first and last elements of l are duplicated at the beginning and end of the list, respectively. The new list should have: The first element of the original list inserted once at the beginning The last element of the original list inserted once at the end You must not modify the original list. ### Constraints The input list will contain at least two elements\ The list can contain elements 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 ``` >>> double_ends([10, 20, 30]) [10, 10, 20, 30, 30] >>> double_ends(['a', 'b', 'c']) ['a', 'a', 'b', 'c', 'c'] >>> double_ends([1, 2]) [1, 1, 2, 2] >>> double_ends([5, 6, 7, 8]) [5, 5, 6, 7, 8, 8] ``` ## Your task Implement this function: ```python def double_ends(l: list) -> list: ``` 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: `l`. ## Example **Input** ``` [10, 20, 30] ``` **Output** ``` [10, 10, 20, 30, 30] ``` Write a function extract_email_username that takes an email address string of the form "[email protected]" and returns just the username part — that is, everything before the @ symbol. ### Constraints The input will always be a valid email address containing exactly one @ symbol. The username can contain letters, numbers, and symbols like dots or underscores. The domain part is irrelevant and should not be returned. 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 ``` >>> extract_email_username("[email protected]") "ananya.sharma" >>> extract_email_username("[email protected]") "rahul123" >>> extract_email_username("[email protected]") "priya_r" >>> extract_email_username("[email protected]") "v.kumar" ``` ## Your task Implement this function: ```python def extract_email_username(email: 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: `email`. ## Example **Input** ``` "[email protected]" ``` **Output** ``` 'ananya.sharma' ``` Write a function shuffle_digits(num) that takes a 4-digit positive integer and shuffles the digits in the order 2413. That is The 2nd digit from left becomes the 1st\ The 4th digit from left becomes the 2nd\ The 1st digit from left becomes the 3rd\ The 3rd digit from left becomes the 4th ### Example ``` >>> shuffle_digits(1234) 2413 >>> shuffle_digits(2413) 4321 >>> shuffle_digits(4321) 3142 >>> shuffle_digits(3142) 1234 ``` 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. ## Your task Implement this function: ```python def shuffle_digits(num: 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: `num`. ## Example **Input** ``` 1234 ``` **Output** ``` 2413 ```