Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

user defined functions python

# Function below finds the sum of its two parameters
def sum(val1, val2): 
	return val1 + val2;

print(sum(3, 4)) # 7

# Function below accepts any number of parameters
def sum_numbers(*vals):
	total = 0
	for val in vals: 
		total+=val
	return total

print(sum_numbers(1, 2, 3, 4)) # 10

 
PREVIOUS NEXT
Tagged: #user #defined #functions #python
ADD COMMENT
Topic
Name
8+1 =