Return more than one value
def calc(x, y):
a = x+y
b = x*y
return a, b
t = calc(4, 5)
print(t)
print(type(t))
z, q = calc(2, 3)
print(z)
print(q)
Output:
(9, 20)
<class 'tuple'>
5
6
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
def calc(x, y):
a = x+y
b = x*y
return a, b
t = calc(4, 5)
print(t)
print(type(t))
z, q = calc(2, 3)
print(z)
print(q)
Output:
(9, 20)
<class 'tuple'>
5
6