tutorial |
---|
You can see a function as a fragment of code we can use several times.
For example: If we want to get the sum of two numbers, we can declare a function called sum
that returns the sum of number1
and number2
:
def sum(number1,number2):
return number1 + number2
After the function is declared, we can use it as many times as we want, like this:
total = sum(2,3)
total2 = sum(5,10)
print(total) # Prints 5 on the console
print(total2) # Prints 15 on the console
- Please calculate the sum between
3445324
and53454423
and assign the result to a variable calledsuper_duper
.