About 3,010,000 results
Open links in new tab
  1. The Python return Statement: Usage and Best Practices

    Using the return statement effectively is a core skill if you want to code custom functions that are Pythonic and robust. In this tutorial, you’ll learn that: You use return to send objects from your functions back to the caller code. You can use return to return one single value or multiple values separated by commas.

  2. Python return statement - GeeksforGeeks

    Dec 10, 2024 · Python allows you to return multiple values from a function by returning them as a tuple: Example: In this example, the fun () function returns two values: name and age. The caller unpacks these values into separate variables. We can also return more complex data structures such as lists or dictionaries from a function:

  3. Python Return Function [With Examples] - Python Guides

    Oct 30, 2024 · Let’s create a function with a return statement to return a result or value from the function. Suppose you have a business where you need to apply a sales tax to a product’s price. For that, you have to create a function that applies sales tax and returns the final price. total_price = price + (price * tax_rate) return total_price.

  4. python - How do I get ("return") a result (output) from a function

    To use the value in the caller you can either use it directly in a statement or capture the value in a variable. Here's some code to demonstrate this: x = 'hello world' return x # return 'hello world' would do, too. # foo() Effectively, there are two ways: directly and indirectly.

  5. Python return Keyword - W3Schools

    The return keyword is to exit a function and return a value. Statements after the return line will not be executed: print("Hello, World!") Define a function using the keyword def. Read more about functions in our Python Functions Tutorial. Python Keywords.

  6. What is Python Return Statement? - Python Guides

    Jan 8, 2025 · In this tutorial, I will explain what is Python return statement. As a Python developer working on a project for one of my clients, I often came across a scenario while working on functions to use a return statement.

  7. Mastering the `return` Command in Python - CodeRivers

    Feb 5, 2025 · In Python, the return command is a fundamental and powerful statement that plays a crucial role in function programming. It allows functions to send back a value or multiple values to the point where the function was called. Understanding how to use the return command effectively is essential for writing clean, modular, and efficient Python code.

  8. Python's return Method: A Comprehensive Guide - coderivers.org

    Mar 28, 2025 · In Python programming, the return statement plays a crucial role in functions. It is the mechanism by which a function can send a value (or values) back to the code that called it. Understanding how the return method works is essential …

  9. Python Functions - Python Guides

    Real-World Examples. Functions are essential across various Python applications: ... Palindrome Number in Python Using Function; Python Return Function; ... Learn about Functions in Python: Create reusable blocks of code using the `def` keyword, pass arguments, return values, and organize your logic efficiently. ...

  10. Return a Function in Python - How-To Guide with Examples - Dive Into Python

    May 3, 2024 · Returning a function from a function means that a function is created and returned as output of another function. This is possible in Python because functions are first-class objects, which means they can be passed around just like any other object such as …

  11. Some results have been removed
Refresh