easy +10 pts

Variadic Sum Function

Write a function that takes any number of arguments and returns their total sum.

Write a function `variadic_sum(*args)` that accepts any number of numeric arguments (integers or floats) and returns their sum. If no arguments are given, the function should return `0`. For example, `variadic_sum(1, 2, 3)` returns `6`. You do not need to handle non-numeric types.

Constraints

The number of arguments is between 0 and 1000. Each argument is an integer or float. The sum is guaranteed to fit within Python's float or int range.

Example

>>> variadic_sum(1, 2, 3)
6
>>> variadic_sum(1.5, 2.5)
4.0
>>> variadic_sum()
0
10 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use the built-in `sum` function.
Remember that `args` is a tuple containing all the arguments.
If no arguments are passed, `args` is empty, and `sum` of an empty iterable is 0.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.