Пользовательские функции 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
Wissam