Intermediate Python

Add Values

You are asked to write a Python function named add_values that adds all given values. The function should be able to take any number of positional arguments, potentially including zero, and return the sum of these arguments. The arguments can be assumed to be integers or floating-point numbers, and they can be positive, negative, or zero. If no arguments are provided, the function should return 0.
The program should print the result returned by the function. This should be a single number, representing the sum of all input values.
add_values(1, 2, 3, 4, 5)
add_values(10.5, 20.3, -5.3)
Note: The function add_values is not supposed to print the result, but to return it.


Time limit: 0.2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue