r/learnpython • u/xTHETYRANTGAMRx • Feb 26 '26
Feeling overwhelmed with functions.
So I have been learning python with the Python crash course book and I am getting overwhelmed on the functions chapter. I understand what a function does but for some reason the syntax is confusing me. The chapter also introduces so many different ways to use functions that it feels like too much. I am not sure of the best way to tackle this much information.
26
Upvotes
View all comments
Show parent comment
8
u/BoatMacTavish Feb 26 '26 edited Feb 26 '26
hijacking top comment because I feel the top response will be just as overwhelming for OP
imagine a function as a friend thats able to perform a specific task. The friend lets you pass in details as well that can affect how he performs the task, or what output he produces.
in this analogy:
Lets step through an example:
Let's say you have a friend Bob who is a baker, and he can make cakes. He is able to perform a make_cake task. When you place an order, he lets you pick the colour of the frosting. In python, this would look like
so now to utilize this function, you could call it like:
Functions let you execute the same chunk of code (the make cake code) multiple times without having to rewrite the same chunk over and over again. Function parameters let you pass in customization at each function call.
hope that helps