Use return value in another function - python Last Updated : 07 Jan, 2025 Comments Improve Suggest changes 3 Likes Like Report In Python, one function’s return value can be used in another, making code cleaner and more modular. This approach simplifies tasks, improves code reuse, and enhances readability. By breaking down logic into smaller functions that share data, you create flexible and maintainable programs. Let’s explore this with an example.How It Works:Function with a Return Value: A function calculates a result or performs an operation and returns the output using the return statement.Pass the Return Value: Another function can use this returned value as an argument or input for further operations.Combining Functions: This helps in chaining functions together to create a workflow or pipeline.Here's an example : Python # Function that calculates the square of a number def square(number): return number ** 2 # Function that adds 10 to a number def add_ten(number): return number + 10 # Use the return value of square in add_ten result = add_ten(square(4)) print(result) Output26 Explanation:square(4) calculates 42=164^2 = 1642=16 and returns 16.add_ten(16) adds 10 to 16 and returns 26.Example : Python # Function to multiply two numbers def multiply(x, y): return x * y # Function to calculate the result of multiplying and then adding 5 def multiply_add(x, y): product = multiply(x, y) # Using return value of multiply() here return product + 5 # Using multiply_and_add function result = multiply_add(3, 4) # Passes 3 and 4 to multiply_and_add print(result) OutputFinal price: 84.00 Explanation:multiply(x, y): This function multiplies two numbers x and y and returns the product.multiply_add(x, y): This function first calls multiply(x, y) to get the product and then adds 5 to the result.We call multiply_add(3, 4), which uses the return value of multiply(3, 4) (which is 12), and then adds 5, resulting in 17. Create Quiz Comment H harshitwn5p Follow 3 Improve H harshitwn5p Follow 3 Improve Article Tags : Python python Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 4 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 3 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 3 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 3 min read StatsModel Library - Tutorial 3 min read Learning Model Building in Scikit-learn 6 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 5 min read Build a REST API using Flask - Python 3 min read Building a Simple API with Django REST Framework 3 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like