Write a function shuffle_sentence(sentence, order) that takes a string sentence containing three words separated by spaces and a tuple order specifying the shuffling order.
The function should return a string with the words of the sentence shuffled according to the specified order.
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.
sentence = "apple banana orange", order = (0, 2, 1) -> "apple orange banana" Explanation: 0 - apple , 2 - orange, 1 - banana
sentence = "cat dog mouse", order = (2, 1, 0) -> "mouse dog cat" Explanation: 2 - mouse, 1 - dog, 0 - cat
Implement this function:
def shuffle_sentence(sentence, order):
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: sentence, order.
Input
"apple banana orange"
(0, 2, 1)
Output
'apple orange banana'
Write a function shuffle_sentence(sentence, order) that takes a string sentence containing three words separated by spaces and a tuple order specifying the shuffling order. The function should return a string with the words of the sentence shuffled according to the specified order. 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. ### Examples ``` sentence = "apple banana orange", order = (0, 2, 1) -> "apple orange banana" Explanation: 0 - apple , 2 - orange, 1 - banana sentence = "cat dog mouse", order = (2, 1, 0) -> "mouse dog cat" Explanation: 2 - mouse, 1 - dog, 0 - cat ``` ## Your task Implement this function: ```python def shuffle_sentence(sentence, order): ``` 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: `sentence`, `order`. ## Example **Input** ``` "apple banana orange" (0, 2, 1) ``` **Output** ``` 'apple orange banana' ``` Write a function n_unique_letters_in_exactly_one_of(s1, s2) that takes two strings as input and returns the number of unique letters that are present in exactly one of the strings but not in both. Assume the strings will have only alphabets (both uppercase and lowercase). The letters should be compared in case insensitive manner ('A' and 'a' are considered same). Hint: Use set operations to find this. 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 ``` >>> n_unique_letters_in_exactly_one_of("APPLE", "plum") ``` "a", "e", "u" and "m" are the characters that are present in exactly one of the strings. ## Your task Implement this function: ```python def n_unique_letters_in_exactly_one_of(s1: str, s2: str) -> 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: `s1`, `s2`. ## Example **Input** ``` "APPLE" "plum" ``` **Output** ``` 4 ``` Write a function that takes an integer n and: doubles it if it is even, otherwise returns its square. 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. ### Examples ``` >>> double_if_even_else_square(8) >>> double_if_even_else_square(9) ``` ## Your task Implement this function: ```python def double_if_even_else_square(n): ``` 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** ``` 8 ``` **Output** ``` 16 ```