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

Add MCQ for modifying data in lists #201

Merged
merged 2 commits into from
Jun 14, 2016

Conversation

derekhoward
Copy link
Contributor

No description provided.

@iglpdc
Copy link
Contributor

iglpdc commented Jan 15, 2016

I think the challenge is nice, but a bit confusing, because it contains two questions. You ask about what the operator * does with list and also about in-place modification. I think I'd be better if you address these two questions into two separate parts of your challenge. (I'm not the maintainer of the lesson, just giving my opinion.)

About the first part, we don't talk much about how copies are done in Python (this is more advanced material, I think), so I'd avoid "copies of the references". As they have seen in the lesson that + concatenates the strings, you could ask what they think the operator * should do. (This is a good lesson on keeping standard meanings of operators consistent when overloading them).

Your example could exploit the similarity with the same expression in numpy (multiplying an array by a number makes an element-wise multiplication) to stress operator overloading. My first guess is maybe that repeats = counts * 2 makes repeats equal to [4, 8, 12, 16, 20]. So if you add that to your choices A and B, you kinda cover that operators in Python can be overloaded to do very different things.

The second part of the challenge could go on modifying counts and asking what happens to repeats.

Simplified the exercise to focus on operator overloading.
@derekhoward
Copy link
Contributor Author

Thanks for the feedback. I simplified the exercise to focus on the first part of operator overloading. I think you're right that it may be best to avoid talking about creating copies of references with the * operator and the second question might be too subtle of a problem to include.

@gvwilson gvwilson merged commit 4e07e4a into swcarpentry:gh-pages Jun 14, 2016
rgaiacs pushed a commit to rgaiacs/swc-python-novice-inflammation that referenced this pull request May 6, 2017
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

Successfully merging this pull request may close these issues.

None yet

3 participants