A function in Python is a reusable chunk of code that is used to accomplish a single, related operation. Functions provide your program with more modularity and allow you to reuse a lot of code. As you may be aware, Python includes a number of built-in functions, such as print(), but you may also construct your own. User-defined functions are what they’re called.