python-novice-inflammation
python-novice-inflammation copied to clipboard
expression and assignment statements
At the beginning of Python Fundamentals, we start with 3+5*4
, an expression statement that outputs 23
. We then introduce variables and assigning values with weight_kg = 60
, an assignment statement which doesn't have an output. I wonder if beginners will be puzzled by this difference. Do you think it's worth adding one or two lines explaining the difference between these two expressions and introducing the concept of simple statements?
It is indeed a very interesting and fundamental concept in python (and actually many languages) to distinguish between expressions and statements or in this concrete case between expression statements and assignment statements.* But I suspect that really the application of this knowledge in practice is rarely necessary. Even more so as the target audience just starts off and probably has more pressing matters.
But your concern was about confusion and I agree that it seems a bit inconsistent that the rest of the lesson so eagerly uses print
instead of expression statements when the first line they ever type seems to suggest that the print function isn't really that necessary. But after their first two lines of python
code, they (or at least I) would probably be concerned with more concrete matters. I guess, if someone should notice that, one could discuss it shortly in the next break or the like.
It remains to investigate if the instructors themselves know enough details about this in order to appropriately answer a potential question. Should it happen to be a FAQ, it might be just nice to have a note in there for the instructors to be prepared. But I doubt that this would be necessary.
*This first sentence already shows that to be precise one should actually first introduce an expression and then further explain that python interprets an expression on its own as an expression statement here and that this expression statement in this concrete case (in some prompts under some conditions) triggers the interpreter to actually print something to the screen.