EasyPython

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). Return 0 if none.
  • "join" → join all positional args as strings with the separator from kwargs.get("sep", " ").
  • "merge" → merge all **kwargs into a single dict and return it.

Examples

  • solve("sum", 1, 2, 3, 4)10
  • solve("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"]
Output: "a-b-c"
Test #3Merge kwargs
Input: ["merge"]
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