← Back to all posts

This is a PRACTICE question. Define the function sum2(...) which receives two integer numbers n1 and n2 as parameters and it returns the sum of those numbers.
As an example, the following code fragment:
res = sum2(2,5)
print (res)
should produce the output:
7

John_WardWard (213)

@timmy_i_chen I think this is somebody cheating their homework. They've got multiple of these questions which sound like homework.

timmy_i_chen (1036)

@John_WardWard The user in question has been banned.

JoshDaBosh (77)
``````def sum2(n1, n2):
return int(n1)+int(n2)``````
TZLALA (0)

@JoshDaBosh Why it didn't works

n1 = int(input("Put a integer number"))
n2 = int(input("Put another integer number"))
def sum2(n1, n2):
return n1 + n2

JoshDaBosh (77)

@TZLALA you didn't call the function and didn't indent properly

JosephBarroso (1)

def sum2(a, b):
return a + b

TZLALA (0)

@JosephBarroso Why it didn't work

n1 = int(input("Put a integer number"))
n2 = int(input("Put another integer number"))
def sum2(n1, n2):
return n1 + n2