Python supports multiple returns from a single function which is not possible in most of the other programming languages such as Java, C, etc.
Input
def func():
return 1, 2, 3, 4, 5
one, two, three, four, five = func()
print(one, two, three, four, five)
output
(1, 2, 3, 4, 5)
Try Solving some question with this technique, and paste your some interesting code in the comment section.
![:smiling_face_with_three_hearts: :smiling_face_with_three_hearts:](https://community.edyoda.com/images/emoji/twitter/smiling_face_with_three_hearts.png?v=12)
1 Like
def all_operation_function():
n1 = int(input('Enter no 1: '))
n2 = int(input('Enter no 1: '))
return n1+n2, n1-n2, n1*n2, n1/n2, n1//n2, n1**n2
def detail_function(add, subs, multi, divi, modulus, exponent ):
return f'Addition of the numbers is {add} \nSubstractio of the numbers is {subs} \nMultiplication of the numbers is {multi} \nDivision of the numbers is {divi} \nModulus of the numbers is {modulus} \nExponent of the no is {exponent}'
n1, n2, n3, n4, n5, n6 = all_operation_function()
print(detail_function(n1, n2, n3, n4, n5, n6))
1 Like