No arguments needed for function calculate_price
I wrote a program where there was no need of an argument to be passed in function. IT would work exactly the same. Then, why are we passing an argument here.
Jeff MudayTreehouse Moderator 23,486 Points
Good observation! One of the things that I enjoy about programming is there are so many right ways to do things, not just one.
The video is setting you up to learn the concept of parameter passing. You will need to master this design pattern.
In simple programs, you can make the choice to pass parameters in the global scope. But as your programs become more complex, or you are working on a programming team where your functions are part of a library, it is good practice to use parameter passing and good naming conventions to avoid name-space conflicts as well as abstraction.
There are many reasons to refactor code such as to make it logically clearer, fit more use cases, more modular/portable, or more efficient. Using well-named arguments will make refactoring easier.
Sean MTreehouse Moderator 7,332 Points
From my understanding, using functions in python or using methods in java can help reuse code in the program so you don't have to repeat yourself.
And if you need to change the formula or the variables used, you can just change the function/method, instead of searching through the entire program for the code you want to edit.
I get it now! Thanks for clearing my doubt, Sir!