Functions

Once we have variables, we can use them to do some pretty interesting things. The most interesting thing is to build functions. Python functions are blocks of code that we can build to do a specific job. We build these functions once, and then we can reuse them in our code just by typing the name. This is really helpful. For example, if I need to write a program that adds two numbers (a calculator, for example), I do not want to have to write three or four lines of code every time I want to add two numbers. Instead, I want to write one function that can add two numbers together, and then use that single line whenever I need to add numbers.

Before we begin building functions of our own, we need to also know that Python has a lot of amazing ...

Get Python Projects for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.