For more information on concepts covered in this lesson, you can check out How to Write Beautiful Code With PEP 8.
00:11 The main program calls the mini-program and sends information that the mini-program will need as it runs. When the function completes all of its actions, it may send some data back to the main program that’s called it.
00:25 The primary purpose of a function is to allow you to reuse the code within it whenever you need it using different inputs if required. When you use functions, you’re extending your Python vocabulary.
This lets you express the solution to your problem in a clearer and more succinct way. In Python, by convention, you should name a function using lowercase letters with words separated by an underscore, such as
do_something(), as seen on-screen.
You need to add parentheses (
()) after the function name when you call it. Since functions represent actions, it’s best practice to start your function names with a verb to make your code more readable. In the next section of the course, you’ll see how to define functions with no input parameters.
Become a Member to join the conversation.