Languages
[Edit]
EN

Python - functions

0 points
Created by:
Molly
351

In this article, we would like to show you how to create and call a function in Python.

Quick solution:

 

1. Create function

Edit

In the Quick solution we presented how to create a function without arguments.

In this example, we create a function that takes 2 arguments separated by a comma (ab) and returns the sum of them.

2. Call function

Edit

You can call a function by typing the function name with the parenthesis. If your function takes some arguments, you need to pass them when the function is called (in our example a = 1, b = 2).

Output:

Alternative titles

  1. Python - how to create and call function
  2. Python - how to define and call function
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Python - fundamentals

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join