def add(numbers):
result = 0
for number in numbers:
result += number
# add([3,5,7])
If we need a function, which behaves as shown below we have *args to the the rescue in python
add(1,2)
add(1,2,3)
add(1,2,3,4,5,6)
A sample implementation of add numbers using *args
def add(*args):
print(f"Type of args is {type(args)} and value is {args} ")
result = 0
for arg in args:
result += arg
return result
print(add(1))
print(add(1,2))
print(add(1,2,3,4,5,6,7,8,9))
Now if want a function with variable arguments with names
add(number1=1, number2=2, number3=3)
Developer Work-Organization Workflow
Version Control Systems
This is a software system where developers commit (send/store) the source code of the project.
Version Control Systems help in navigating through history of changes done in the code
It also helps in multiple team members working on same project.
How to test the code
Manually: debug the code by passing multiple inputs and check all the conditions around
Test Harness Tools/Unit Testing Tools: Every Language supports unit testing frameworks to test the written code.