Write a function traffic_signal(vehicle_type, signal, emergency) that tells a road user what to do.
emergency is True and vehicle_type is "ambulance", return "Proceed Carefully".signal:
"red": return "Stop"."yellow": return "Slow Down"."green": return "Cross" if vehicle_type is "pedestrian", and "Go" for any other vehicle type.signal, return "Invalid Signal".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.
traffic_signal("car", "red", False) -> 'Stop'
traffic_signal("pedestrian", "green", False) -> 'Cross'
Implement this function:
def traffic_signal(vehicle_type: str, signal: str, emergency: bool) -> 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: vehicle_type, signal, emergency.
Input
"car"
"red"
False
Output
'Stop'
Write a function `traffic_signal(vehicle_type, signal, emergency)` that tells a road user what to do. - If `emergency` is `True` and `vehicle_type` is `"ambulance"`, return `"Proceed Carefully"`. - Otherwise it depends on `signal`: - `"red"`: return `"Stop"`. - `"yellow"`: return `"Slow Down"`. - `"green"`: return `"Cross"` if `vehicle_type` is `"pedestrian"`, and `"Go"` for any other vehicle type. - For any other `signal`, return `"Invalid Signal"`. 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 ``` traffic_signal("car", "red", False) -> 'Stop' traffic_signal("pedestrian", "green", False) -> 'Cross' ``` ## Your task Implement this function: ```python def traffic_signal(vehicle_type: str, signal: str, emergency: bool) -> 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: `vehicle_type`, `signal`, `emergency`. ## Example **Input** ``` "car" "red" False ``` **Output** ``` 'Stop' ``` The list `words` has exactly four strings. Write a function `join_even_index_strings(words)` that returns one string made by joining the strings at the even indices, which are index 0 and index 2, in this order, with nothing in between. 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 ``` join_even_index_strings(["apple", "banana", "cherry", "mango"]) -> 'applecherry' join_even_index_strings(["red", "green", "blue", "yellow"]) -> 'redblue' ``` ## Your task Implement this function: ```python def join_even_index_strings(words: list) -> 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: `words`. ## Example **Input** ``` ["apple", "banana", "cherry", "mango"] ``` **Output** ``` 'applecherry' ``` Write a function `make_dict_from_elems_in_index(keys, values, index)` that returns a dictionary with just one entry: the key is the element of `keys` at position `index` and the value is the element of `values` at position `index`. The index is valid for both lists, and it can be negative. The two lists can have different lengths. 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 ``` make_dict_from_elems_in_index(['apple', 'banana', 'cherry'], [10, 20, 30, 40], 1) -> {'banana': 20} make_dict_from_elems_in_index(['apple', 'banana', 'cherry'], [10, 20, 30, 40], -1) -> {'cherry': 40} ``` ## Your task Implement this function: ```python def make_dict_from_elems_in_index(keys: list, values: list, index: int) -> dict: ``` 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: `keys`, `values`, `index`. ## Example **Input** ``` ['apple', 'banana', 'cherry'] [10, 20, 30, 40] 1 ``` **Output** ``` {'banana': 20} ```