Python Tutorial for Beginners 8: Functions

Corey Schafer · 1.4M views · 2017 · 21:48

Open on YouTube

Python, Ruby & scripting languagesEducation & learningtutorial

Why Stack Overflow recommends it

Stack Overflow users link it when a question shows the asker is confused about basic function concepts such as return values, and they want a beginner-friendly walkthrough.

Recommended by 3 people across 3 different months, 2017 to 2021.

What it is

A beginner-level Python tutorial by Corey Schafer, part of his Python Beginner series, covering how to define functions, pass arguments and return values. It is a screen-recorded walkthrough with code available on GitHub.

What people said

Recommends Luke · 2017-08 · Stack Overflow · on “Unable to break a python while loop inside a function”

@TaraF13 I'd definitely suggest watching this video [this video] . It will help you get a better understanding of functions in Python.

Recommends little-eye · 2020-09 · Stack Overflow · on “How can I get the length of a string to return back?”

Learn about void functions vs functions with return statements: [this video] Void function: >>> def function(param): ... print('Function started.') ... param*10 ... >>> x = function(5) Function started. >>> print(x) None The function above does the calculation 5*10 when you call it during the assignment statement, but x will equal to None because you did not state what value the function should output or "return". Function with a return statement: >>> def function(param): ... print('Function started.') ... return param*10 ... >>> x = function(5) Function started. >>> print(x) 50 Tip: Functions don't always have to have return functions. For example, you could have a function that prints out a str

Recommends Matiiss · 2021-08 · Stack Overflow · on “Understanding the code behind a gridtraveller”

I suggest tho that you take a look at some basic tutorials (such as these by Corey Schafer [LINK] ) specifically this one (on topic): Python Tutorial for Beginners 8: Functions [this video] , also this is on topic about recursion [LINK] and search for other sources if you need to understand this better