The way to return several variables at once.
Return of Function is an inevitable essence in functional programming. But sometimes functions produce more than one value for return.
In this case, it may be one of the answers to make a list of values.
However, Python has a much more simple solution, which is called 'packing'. It literally means packing independent values into iteration data types.
# Just array values for return.
# Then, the array automatically turns into a tuple of values.
def operations(a, b):
add = a + b
sub = a - b
mul = a * b
rem = a % b
return add, sub, mul, rem
a, b = map(int, input().split())
# And so, here is the tuple data type in iterations.
for i in operations(a, b):
print(i)
Author And Source
이 문제에 관하여(The way to return several variables at once.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@ziwe_ek/The-way-to-return-several-variables-at-once저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)