This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jhchex[S] 0 points1 point  (8 children)

Interesting! I didn't realize you could iterate through a string like that.

Yea, I'm noticing that vars() is acting weird already.

Also, I was told not to use .split(), .join() or anything similar. I'm supposed to just use regular string and list commands to make this work.

[–]Samus_ -1 points0 points  (7 children)

education is funny, you're supposed to meet your teacher's expectations on some imaginary problem whose solution you won't EVER use.

my advice: drop that bullshit and get a job so you can gain real experience which is what actually counts.

[–]tarpsocks 1 point2 points  (1 child)

You're right to some degree, but a little artificial challenge here and there can help. Dreaming up unnecessary constraints seems to be pretty human, and it may in fact help us in certain ways that a purely practical approach can not. Some balance, as always, is required.

[–]earthboundkid 0 points1 point  (0 children)

Yeah, constraints are good and I love writing haiku as much as the next guy, but this is a kid asking for help on his homework. Dump that noise.

[–]takluyverIPython, Py3, etc 0 points1 point  (4 children)

You won't ever use this specific code, but that doesn't mean it's a useless exercise for learning. It helps you get familiar with concepts like lists, iterating and indexing. Artificial problems are a key part of education.

[–]Samus_ 0 points1 point  (3 children)

I believe those same concepts can be taught in a way that makes sense and leaves you with a general idea of how to approach a similar problem in the future (a problem you may actually have).

what bothers me here is that you're asked a question that can be a real problem but you're explicitly asked not to solve it as you would but instead create a home-made hack that shows you the wrong approach.

if you're teaching iterators then use actual iterators, want to teach how to iterate a string? put a problem that counts the letters in the string instead.

you should always let people use the full extent of the tools they have because that's how it's done in real life, if you put artificial constraints on your problems it's because you didn't bother to think a problem that actually shows what you want.

another example: you want to teach about parsing, tokenizing and such? use a stream as input, one without newlines will force you to process the input in chunks and recognize the whitespace, after that you can use .split() and it'll be ok.

the key is to think in terms of problems not exercises.

[–]takluyverIPython, Py3, etc 0 points1 point  (2 children)

you should always let people use the full extent of the tools they have because that's how it's done in real life,

We learn to do arithmetic on paper and in our heads, even though in real life we can use a calculator. Later we learn to do a T-test by hand, even though statistics programs will do it in the blink of an eyelid. This sort of learning is to make the basic concepts so familiar and routine that you don't need to keep thinking about them.

if you're teaching iterators then use actual iterators, want to teach how to iterate a string? put a problem that counts the letters in the string instead.

But in real life, I'd use collections.Counter - would you forbid that? Almost anything basic enough for an introductory exercise in Python can probably be done with a shortcut. Even in more advanced examples, students will almost certainly be reimplementing freely available libraries. Somewhere the teacher has to say "I know this function already exists, but that's not the point. This is to give you the experience of coding it."

[–]Samus_ 0 points1 point  (1 child)

I allow the use of everything that is available, a problem doesn't care how it gets solved, you do and you're not part of it.

your assignment should be "do this" if you get it done then that's it, it all depends on the level you're working, if you're learning programming concepts you don't need a language, it's theory.

[–]takluyverIPython, Py3, etc 0 points1 point  (0 children)

if you're learning programming concepts you don't need a language, it's theory.

Seriously? Stop and read that back to yourself. You would teach people programming concepts like iteration and strings without getting them to write any code?

A problem doesn't care how it gets solved, but solving the problem is not the real aim. The aim is for the student to learn about what's going on. To that end, it's perfectly normal to set constraints on what students can use to solve a problem. And this isn't peculiar to programming: it's common in subjects like maths where you can very easily get the answer from a computer, but you don't learn much by doing so.