Functions and return parameters list
Program is:
#
# functions and return parameters list
#
def function_1(a,b):
return [a+b]
def function_2(a,b):
suma = a + b
if a > b:
minimum =b
else:
minimum = a
return [suma, minimum]
def function_3(a,b):
suma = a + b
if a > b:
minimum = b
else:
minimum = a
if a > b:
maximum = a
else:
maximum = b
return [suma, minimum, maximum]
X = 10
Y = 20
Z = function_1(X,Y)
W = function_2(X,Y)
A = function_3(X,Y)
print(' If a=', X, 'and b= ', Y, 'than a+b=', Z[0])
print(' If a=', X, 'and b= ', Y, 'than a+b=', W[0], 'minumum is', W[1] )
print(' If a=', X, 'and b= ', Y, 'than a+b=', A[0], 'minumum is', A[1],
'and maximum is', A[2])
Results are:
============ RESTART: /Users/ionivan/Documents/FunctionReturnList.py ===========
If a= 10 and b= 20 than a+b= 30
If a= 10 and b= 20 than a+b= 30 minumum is 10
If a= 10 and b= 20 than a+b= 30 minumum is 10 and maximum is 20
(April 02, 2022)
#
# functions and return parameters list
#
def function_1(a,b):
return [a+b]
def function_2(a,b):
suma = a + b
if a > b:
minimum =b
else:
minimum = a
return [suma, minimum]
def function_3(a,b):
suma = a + b
if a > b:
minimum = b
else:
minimum = a
if a > b:
maximum = a
else:
maximum = b
return [suma, minimum, maximum]
X = 10
Y = 20
Z = function_1(X,Y)
W = function_2(X,Y)
A = function_3(X,Y)
print(' If a=', X, 'and b= ', Y, 'than a+b=', Z[0])
print(' If a=', X, 'and b= ', Y, 'than a+b=', W[0], 'minumum is', W[1] )
print(' If a=', X, 'and b= ', Y, 'than a+b=', A[0], 'minumum is', A[1],
'and maximum is', A[2])
Results are:
============ RESTART: /Users/ionivan/Documents/FunctionReturnList.py ===========
If a= 10 and b= 20 than a+b= 30
If a= 10 and b= 20 than a+b= 30 minumum is 10
If a= 10 and b= 20 than a+b= 30 minumum is 10 and maximum is 20
(April 02, 2022)
Comments
Post a Comment