About 1,600,000 results
Open links in new tab
  1. Assign Function to a Variable in Python - GeeksforGeeks

    Jan 24, 2026 · In Python, functions are first-class objects, meaning they can be assigned to variables, passed as arguments and returned from other functions. Assigning a function to a variable enables …

  2. Using and Creating Global Variables in Your Python Functions

    In this tutorial, you'll learn how to use global variables in Python functions using the global keyword or the built-in globals() function. You'll also learn a few strategies to avoid relying on global variables …

  3. Python Functions - W3Schools

    Python Functions A function is a block of code which only runs when it is called. A function can return data as a result. A function helps avoiding code repetition.

  4. python - Assigning a function to a variable - Stack Overflow

    In the first example, you're setting x to be the function lambda: print(20). So x now refers to that function. x() is not the function, it's the call of the function. In python, functions are simply a type of variable, …

  5. How can I use a global variable in a function? - Stack Overflow

    Jul 11, 2016 · In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a new value anywhere within the function’s body, it’s assumed to be a local. If a …

  6. Explicitly define datatype in a Python function - GeeksforGeeks

    Jul 15, 2025 · Unlike other programming languages such as Java and C++, Python is a strongly, dynamically-typed language. This means that we do not have to explicitly specify the data type of …

  7. *args and **kwargs in Python - GeeksforGeeks

    Sep 20, 2025 · In Python, *args and **kwargs are used to allow functions to accept an arbitrary number of arguments. These features provide great flexibility when designing functions that need to handle a …

  8. How to Use a Variable from Another Function in Python

    Jul 23, 2025 · Using a variable from another function is important for maintaining data consistency and code reusability. In this article, we will explore three different approaches to using a variable from …

  9. Python Functions - GeeksforGeeks

    6 days ago · Python Functions are a block of statements that does a specific task. The idea is to put some commonly or repeatedly done task together and make a function so that instead of writing the …

  10. Variable Length Argument in Python - GeeksforGeeks

    Jul 23, 2025 · What is Python **kwargs? In Python, **kwargs is used to pass a keyworded, variable-length argument list. We call kwargs with a double star. The reason for this is that the double star …