About 474,000 results
Open links in new tab
  1. Python Functions (With Examples) - Programiz

    We can create two functions to solve this problem: Dividing a complex problem into smaller chunks makes our program easy to understand and reuse. Let's create our first function. def greet (): print ('Hello World!') Here are the different parts of the program: Here, we have created a simple function named greet () that prints Hello World!

  2. Python Functions - GeeksforGeeks

    Mar 10, 2025 · Python Functions is a block of statements that return the specific task. The idea is to put some commonly or repeatedly done tasks together and make a function so that instead of writing the same code again and again for different inputs, we can do the function calls to reuse code contained in it over and over again.

  3. Functions in Python – Explained with Code Examples

    Jul 28, 2021 · In this tutorial, we shall learn about user-defined functions in Python. When you started coding in Python, you'd have used the built-in print() function in your Hello World! program 😀 and the input() function to read in input from the user. So long as you know how to use these functions, you don't have to worry about how they've been implemented.

  4. Python Functions - W3Schools

    In Python a function is defined using the def keyword: To call a function, use the function name followed by parenthesis: Information can be passed into functions as arguments. Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.

  5. 16 Python Functions Exercises and Examples - Pythonista Planet

    In this post, I have compiled a list of examples of functions in Python. Check out these examples and understand how functions work in various scenarios. I hope this will help you get a clear picture of Python functions. Let’s dive right in. 1. Python function that prints a text.

  6. 10+ simple examples to learn Python functions in detail

    Jan 9, 2024 · In this tutorial we will learn about python functions and it's usage covering different scenarios and types. 1. Why use Python functions? This is especially useful if the code in question will be used several times in different parts of your program. You may want to use functions to abstract away some complex code that you need in your programs.

  7. Top 35 Python Programs and Examples - PYnative

    Apr 22, 2025 · This article offers a hands-on approach to understanding Python by presenting a variety of simple programs and examples. From basic arithmetic operations to fundamental control flow structures and data handling, we'll explore practical applications of …

  8. Python functions - Exercises, Practice, Solution - w3resource

    Apr 22, 2025 · This resource offers a total of 105 Python functions problems for practice. It includes 21 main exercises, each accompanied by solutions, detailed explanations, and four related problems. [An Editor is available at the bottom of the page to write and execute the scripts.] 1. Maximum of Three Numbers.

  9. Python Functions - Python Guides

    What are Functions in Python? A function is a block of organized, reusable code that performs a specific task. Functions help break our program into smaller and modular chunks, making it more organized and manageable. Defining a Function. In Python, you define a function using the def keyword, followed by the function name and parameters in ...

  10. An Essential Guide to Python Functions By Examples

    In this tutorial, you’ll learn how to define user-defined Python functions. Here’s a simple function that shows a greeting: print('Hi') Code language: Python (python) This example shows the simplest structure of a function. A function has two main parts: a function definition and body.

  11. Some results have been removed
Refresh