RunestoneInteractive / fopp

Foundations of Python Programming
https://runestone.academy/runestone/static/fopp/index.html
37 stars 120 forks source link

Pr1forloop #255

Closed presnick closed 5 years ago

presnick commented 5 years ago

This is a fix for https://github.com/RunestoneInteractive/fopp/issues/242

presnick commented 5 years ago

Well, unfortunately 13.4-13.5 are not modularly written right now. 13.4 has a function example and 13.5 has a dictionary example. So it's not trivial to just have students read my new 13.6 that explains the construct you're using earlier in the course.

But it might not be so hard to refactor. 13.5 could be explained using enumerate instead of using .item() from a dictionary and would probably make more sense.

The part of 13.4 that applies unpacking to functions could be split off onto a different page. Indeed, we could have everything in the packing and unpacking chapter that deals with functions come after all the stuff that gets us through enumerate. And that stuff could then be taught right after for loops if you wanted to.

Want me to try to do this?

On Sat, Sep 14, 2019 at 6:00 PM Bradley Miller notifications@github.com wrote:

@bnmnetp commented on this pull request.

In _sources/Tuples/TupleAssignmentwithunpacking.rst https://github.com/RunestoneInteractive/fopp/pull/255#discussion_r324439407 :

@@ -139,6 +139,36 @@ More generally, if you have a list of tuples that each has more than two items, loop pulling out information from the tuples, the code will be far more readable if you unpack them into separate variable names right after the word for.

+ +The Pythonic Way to Enumerate Items in a Sequence

Its an interesting problem. We have to order the chapters and some later things are definitely harder than earlier things. But some are not, they are just more esoteric maybe... Not sure. but, many of the courses using FOPP in the Applied Computing program don't get past chapter 12 in one semester.

What I have done as a compromise for some of the projects is to make the first part of the functions chapter an option to read much earlier, for those that really want to teach functions earlier.

I could do the same thing here and just point to this tuple unpacking chapter. The labs can be done without enumerate, its just a nice construct that actually makes the code cleaner and easier for the students to understand and seems to lead to less errors in their code than having to iterate over only the index.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RunestoneInteractive/fopp/pull/255?email_source=notifications&email_token=AAIG7TT4BYTDH2NUQAPPESTQJVNGXA5CNFSM4IWX2DHKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCEX24MI#discussion_r324439407, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIG7TXZBVMYXXZ4DY4IT4TQJVNGXANCNFSM4IWX2DHA .

bnmnetp commented 5 years ago

I don't think doing what you suggest would be too hard, and that would make it modular enough to include earlier in the course, whether they have had functions or not.

Thanks.

presnick commented 5 years ago

I've submitted an updated PR following this proposal. I think it works pretty well. Let me know what you think.

On Sat, Sep 14, 2019 at 6:24 PM Bradley Miller notifications@github.com wrote:

I don't think doing what you suggest would be too hard, and that would make it modular enough to include earlier in the course, whether they have had functions or not.

Thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RunestoneInteractive/fopp/pull/255?email_source=notifications&email_token=AAIG7TWJCPSLMODIQV7H2I3QJVQAFA5CNFSM4IWX2DHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6XFHMQ#issuecomment-531518386, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIG7TQXOARXZNE5UHUNQSTQJVQAFANCNFSM4IWX2DHA .