EasyPro challengePython
Functions — *args and **kwargs
PythonFunctionsArgs
Implement solve(mode, *args, **kwargs) that behaves differently based on mode:
"sum"→ return the sum of all positional args (numbers). Return0if none."join"→ join all positional args as strings with the separator fromkwargs.get("sep", " ")."merge"→ merge all**kwargsinto a single dict and return it.
Examples
solve("sum", 1, 2, 3, 4)→10solve("join", "hello", "world", sep="-")→"hello-world"solve("join", "a", "b", "c")→"a b c"solve("merge", x=1, y=2, z=3)→{"x": 1, "y": 2, "z": 3}
Sample tests
Test #1Join with default separator
Input: ["join","hello","world"]
Output: "hello world"
Test #2Join with custom sep
Input: ["join","a","b","c",{"__kwargs__":{"sep":"-"}}]
Output: "a-b-c"
Test #3Merge kwargs
Input: ["merge",{"__kwargs__":{"x":1,"y":2}}]
Output: {"x":1,"y":2}
Test #4Sum of positional args
Input: ["sum",1,2,3,4]
Output: 10
Test #5Sum with no args returns 0
Input: ["sum"]
Output: 0