Python Practice › Function Programs › Program 29
Return the sum
Write a Python function that returns the sum of two numbers, and show the difference between print and return.
Input
10, 15
Output
25 30
Approach
- A returned value can be used in further calculations.
Solution
def add(a, b): return a + b result = add(10, 15)print(result, add(result, 5))Output
25 30
Learn the concept
New to this topic? Read the lesson, then come back.