Feb-02-2018, 07:11 AM
(Feb-01-2018, 11:11 PM)Gribouillis Wrote: A definition inside a function's body, such as line 10 and 11 does not change the value of any variable named 'a' and 'b' outside the function's body.So (a, b) in Line 6:
def fractionSubtraction(a, b):synchronizes with (a, b) in Line 33:
fractionSubtraction(a, b)So that 'a' and 'b' can be manipulated within the fractionSubtraction function's definition?
Even if that is the case, I still don't see why that's a smart way of doing things. How is that concept NOT ass-backwards? I thought the purpose of a main function was to call a bunch of other functions in order, so that you can manage the code of your program in an organized and object oriented fashion.
Please help me understand. Why is it such a good and wonderful thing that you're always forced to declare and initialize your variables in the main function instead of declaring and initializing them within the fractionSubtraction function definition that is responsible for manipulating their values in the first place anyway? I mean, doesn't declaring and initializing 'a' and 'b' in the main function definition make them global? Whatever happened to the concept of avoiding global variables whenever possible because of scope issues?