Return the sum

EasyFunction Programs · 29 of 39

Write a Python function that returns the sum of two numbers, and show the difference between print and return.

Advertisement
Input
10, 15
Output
25 30

Approach

  1. A returned value can be used in further calculations.

Solution

Python
def add(a, b):    return a + b result = add(10, 15)print(result, add(result, 5))
Output
25 30
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More function programs

← All 39 Function Programs