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

Augmented assignment operator introduced without comment #582

Closed
alex-ball opened this issue Jan 4, 2022 · 2 comments · Fixed by #590
Closed

Augmented assignment operator introduced without comment #582

alex-ball opened this issue Jan 4, 2022 · 2 comments · Fixed by #590
Labels
good first issue Good issue for first-time contributors help wanted Looking for Contributors

Comments

@alex-ball
Copy link
Contributor

The solution to the "Cumulative Sum" challenge in Episode 12 uses the augmented assignment operator += without comment or explanation. In the rest of the episode, the more verbose total = total + whatever syntax is used. The only other occurrence of += is in Episode 18.

My feeling is that += is a useful shorthand but – given how similar it looks to comparisons like !=, >=, <= – deserves a little explanation for anyone who hasn't seen it before. How about having a callout just before "Cumulative Sum" that explains it, then converting "Identifying Variable Name Errors" to use it as well? That would help with retaining it for Episode 18.

Another solution would be to replace the instances in both episodes with the explicit, longer version, which would be less cognitive load but perhaps a bit of a shame.

@alee
Copy link
Member

alee commented Jan 4, 2022

Thanks for catching this! I'm inclined to change it to total = total + number and skip the additional explanation as this lesson often receives feedback that it runs long...

Thoughts?

@alee alee added good first issue Good issue for first-time contributors help wanted Looking for Contributors labels Jan 4, 2022
@alex-ball
Copy link
Contributor Author

As I say, += is a useful keystroke saver, but only once you are comfortable with what it does.

Considering both the cognitive load and timing issues, yes, I'd be quite happy to see the instances of it replaced with total = total + number.

naclomi added a commit to naclomi/python-novice-gapminder that referenced this issue Feb 8, 2022
…tors

one instance is left in episode 18 to emphasize the point of the exercise
@alee alee closed this as completed in #590 Feb 24, 2022
alee pushed a commit that referenced this issue Feb 24, 2022
one instance is left in episode 18 to emphasize the point of the exercise
zkamvar pushed a commit that referenced this issue May 2, 2023
one instance is left in episode 18 to emphasize the point of the exercise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good issue for first-time contributors help wanted Looking for Contributors
Projects
None yet
2 participants