MRU-COMP1701-dev / fopp-functions-first

Foundations of Python Programming: Functions First
GNU Free Documentation License v1.3
0 stars 3 forks source link

Recommended Grammar Corrections for Section 4.3 (Function Invocation) #42

Open CodeIsBrokeYo opened 2 months ago

CodeIsBrokeYo commented 2 months ago

The following paragraphs could be made clearer with the accompanying bolded corrections [note that the mix-up concerning the line numbers has to do with where the code steps' green arrows are; the paragraphs refer to the green arrow's line number, when they should refer to the red arrow's line number since the rest of the context is referring to what is on the line with the red arrow]:

Paragraph 6: "First, note that in Step 1, when it executes line 1, it does not execute lines 4 and 5 [corrected from "2 and 3"]. Instead, as you can see in blue “Global variables” area, it creates a variable named hello whose value is a Python object of the ’function’ class. In the diagram that object is labeled hello() with a notation above it that it is a function."

Paragraph 7: "At Step 2, the next line of code to execute is line 7 [corrected from "5"]. Just to emphasize that hello is a variable like any other, and that functions are Python objects like any other, just of a particular type, line 5 prints out the type of the object referred to by the variable hello. It’s type is officially ‘function’."

Paragraph 8: "Line 8 [corrected from "6"] is just there to remind you of the difference between referring to the variable name (function name) hello and referring to the string “hello”. When we print a string’s type, we see it is of the ’str’ class."

Paragraph 9: "At Step 4 we get to line 10 [corrected from "8"], which has an invocation of the function. When a function is called (or invoked) [added closing parenthesis] by a line of code, the lines of code inside the function’s body are executed in the usual way, but at the end of the function’s code block, the program’s execution jumps back to the [inserted "the"] line of code just after the function invocation."

Paragraph 10: "You can see that by following the next few steps. At Step 5, the green arrow indicates the ’line that just executed’, aka the function’s invocation, and the red arrow shows us the ’next line to execute’ which has moved to the function. We say that control has passed from the top-level program (not ’top’ as in the ’top of the code’ but as in top-hierarchical [corrected from "hierarchial"] level) to the function, "hello()" [inserted comma and quotes around "hello" along with tailing parentheses to differentiate the function name from the English greeting]. After Steps 5 through 8 [corrected from "7"] print out two lines, at Step 9 [corrected from "8"], control will be passed back to the point after where the invocation was started." [removed "By Step 9, that has happened" since that is redundant with the previous sentence]

Paragraph 11: "The same process of invocation occurs again on line 12 [corrected from "10"], with the function’s body (lines 4 and 5 [corrected from "2 and 3"]) getting executed a second time."

Bullet 1 under Note 4.3.2: "They tend to forget the pair of parentheses after the function name. This is particularly common in the functions [added "s"] that do not require parameters. Because the "hello()" [inserted quotes around "hello" along with tailing parentheses to differentiate the function name from the English greeting] function defined above does not require parameters, it’s easy to forget the parentheses."