Python for .NET Developers Transcripts
Chapter: The Python Language
Lecture: Concept: Python function basics
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Creating Python functions always start with the key word def. We're defining a function. We give it a name. This one we're calling evaluate_guess
0:09
following the Python naming conventions of snake case not camel case. Then we can optionally in this case, we want to take some arguments here
0:18
So we're defining some parameters, guess and number. They're positional, but you can also use them keyword style.
0:25
And then these functions have the implementation and they always have a return value. So here we're explicitly returning the single value
0:32
that we can, which is True or False. Is the guess equal to the number or is it not? But if we don't specify a return value the value will be None.
0:42
So if you think of functions as always like returning nullable of something something to that effect even the ones that you would conceptualize
0:49
as void functions, those return None so every function always returns something just sometimes None.