Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression and assignment statements #1006

Open
qyx268 opened this issue Sep 2, 2022 · 1 comment
Open

expression and assignment statements #1006

qyx268 opened this issue Sep 2, 2022 · 1 comment

Comments

@qyx268
Copy link

qyx268 commented Sep 2, 2022

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?

@chillenzer
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants