Python function return

In this Python article we want to learn about Python function return, so as you know Python is one of the most popular programming languages, and that is because it is simple and easy to of the important concepts in Python is function, for example we should know that functions work ? and how they accept arguments and return values. in the article we will write some practical Python function examples with Python return.



Python function returns

When it comes to Python return, one important note that you should remember is that in Python return value can be anything. while most functions return some specific value or object, like string or list, Python functions can return almost any type of data. for example a function can return a complex data structure like dictionary or set, a custom object that you have defined, or even an instance of builtin Python class like int or float. 



Now let’s talk about an example, what if a Python return could be truly unpredictable ? what if it could generate something unique and random every time it’s called.


This is an example of function that demonstrates this idea.

This function uses random module to generate random integer, random floating point number, random boolean value and random string. after that it returns all of these values as a tuple.



This will be the result

Python function return
Python function return

Leave a Comment