1091

Can one ask questions about homework here on Stack Overflow? If so, how should I go about doing so?

What guidelines should users follow when responding to homework questions?


Return to FAQ index

4
  • 28
    Also some may be interested in adding Open letter to students with homework problems. Markdown: [Open letter to students with homework problems](https://softwareengineering.meta.stackexchange.com/q/6166)
    – iBug
    Commented Apr 12, 2021 at 11:01
  • 21
    Markdown link for this Q&A - [How do I ask and answer homework questions?](https://meta.stackoverflow.com/q/334822) (Please do not delete this comment again!)
    – Stephen C
    Commented Apr 1, 2022 at 6:33
  • 1
    @StephenC You could just edit the question and add it there. There is precedent... Commented Jun 7, 2022 at 17:58
  • 5
    No thanks. There is also precedent for people 1) adding the cut-and-paste link to the question, 2) flagging the comment for removal and then 3) someone else edits the question to remove the link! Look at the history of this question. Just leave it alone.
    – Stephen C
    Commented Jun 7, 2022 at 23:01

3 Answers 3

1251

The community has mixed feelings about homework questions. While some feel that students should be able to get an answer to any question they want to ask, others feel that Stack Overflow is not a place for homework questions at all.

This is an attempt to reconcile these two extreme positions in a way that is acceptable to the majority of the community. Note that this post is not the official position of the Stack Overflow administrators, but rather a community-edited effort to provide clear guidelines on how to respond to homework. Individual community members should, of course, use their own judgment.

The guidelines outlined below are rooted in two principles:

  • It is okay to ask about homework. For one, it would be impossible to stop it all, even if we wanted to. Stack Overflow exists to help programmers learn and provide a standard repository for programming problems, both simple and complex, and this includes helping students.

  • Providing an answer that doesn't help a student learn is not in the student's own best interest. Therefore, you might choose to treat homework questions differently than other questions.

Asking about homework

  • Make a good faith attempt to solve the problem yourself first. Users here respond negatively if your question gives them the impression that you're asking them to do your work for you. On the other hand, questions that ask about a specific issue that you're having a problem with usually receive a much better response.

  • Ask about specific problems with your existing implementation. If you can't do that yet, try some more of your own work first or searching for more general help; your professor is likely to be a better resource at this stage than Stack Overflow.

  • Search for already-existing questions about your issue. Try using both the Stack Overflow site search and your favorite search engine. Most search engines allow you to limit results to a single site. For example, you can search Stack Overflow on Google. Definitely try searching for your title and/or the keywords in your title, along with the language tag for the language your question is working with. Look through at least the first several results. People tend to respond negatively if they can easily find a duplicate to your question, particularly if they can do so by just searching for your question's title...

  • Help us understand your baseline. Broad pleas for help like "I have no idea where to start" are problematic, because we can't know your starting level. If you are new to programming, or the specific programming language or system platform you are trying to use, and can't even write or run a simple "Hello world" program, concentrate on solving that in isolation, and return to your actual assignment only when you have solved that. Past that point, it might help to explain the purpose of the course or mention topics you have been taught recently. Do you know how to assign a value to a variable? Do you know how to loop over a range of numbers? Tell us what you already know, and tell us what you already searched for or looked at, and why those resources were not helpful for you.

  • Be aware of school policy. If your school has a policy regarding outside help on homework, make sure you are aware of it before you ask for/receive help on Stack Overflow. If there are specific restrictions (for example, you can receive help, but not full code samples), include them in the question so that those providing assistance can keep you out of trouble. Note that vandalism and/or edits to questions that invalidate existing answers are against policy. Attempts to hide your question after you've received an answer will not be successful and will make it harder for you to get answers to future questions. See also: I've rethought my question about a homework assignment—why can't I get it deleted?

  • Never use code you don't understand. It definitely won't help you later (after school, in later assignments, on tests, etc.), and it could be, at best, very embarrassing if you are asked to explain the code you turned in.

  • Understand the difference between "asking a question about your homework" and "asking a specific question about the code in your homework". You should never ask a question about your homework, because more often than not, it will not meet the recommendations in the rest of these guidelines. Instead, ask about the code you wrote to solve your homework problem and be specific with the inputs, desired outputs, and error messages. It is ideal if you take your code and create a minimal, reproducible example instead of pasting your entire code, especially if it is a long code block.

Answering and moderating homework questions

  • Try to provide an explanation that will lead the asker in the correct direction. Genuine understanding is the real goal for students, but trying to provide that is usually appreciated for any question.

  • Focus on the explanation rather than providing full source code. A student is more likely to learn from clear steps and proper explanation rather than ready-made code. However, if a code example will help understand the solution, don't stop yourself from providing one.

  • Recognize that homework is likely to include artificial constraints, and honor those constraints. Also, be aware that these constraints may affect whether a question should be closed as a duplicate. That said, there is nothing wrong with also including information in your answer about how the problem would normally be solved in the real world. It's helpful for students to learn real-world patterns, and this also makes your answer more useful to future readers.

  • "Lack of effort" is not a reason to close questions. If a homework question shows no good faith effort, you may cast a downvote and refrain from answering, but this is not—in itself—a close reason. (Obviously, if the question does not ask a question, is unclear, does not provide sufficient information to allow it to be answered, and/or answering it would require writing an entire book, then it should still be closed for the appropriate reason.)

  • Failure to comply with these guidelines is not a reason to downvote an answer. Naturally, if the answer is incorrect, low quality, poorly explained, and/or something that you would downvote anyway, then it is fine to do so. Remember that it's not always obvious at first glance that a question is homework, especially when you're not expecting to see it here. You can, according to your judgment, leave comments on the answer with suggestions on how to improve it.

  • Don't ridicule a student because they haven't yet learned something obvious or developed the good habits you'd expect from a seasoned programmer. Do add a respectful comment or answer that points them towards best practices and better style.

  • It's okay to ask if a question is homework if it would help you write a better answer, but always be polite.

12
  • 54
    I agree, but often a question on homework is just the homework, only a quote of the assignment. If people wrote real questions about how to solve the problem, maybe we would help with more homework problems. These people make all homework problems look bad in the eyes of the community. Commented Feb 9, 2021 at 14:20
  • 30
    If everyone fallowed the "Make a good faith attempt to solve the problem yourself first" rule, we wouldn't need to delete half as many posts.
    – Anonymous
    Commented Mar 14, 2021 at 2:42
  • 18
    Never use code you don't understand. -- I used to be on another site, where if anyone who asked the typical, lazy homework question became a nuisance (for example, insulted persons who asked for more details), it was customary to give the answer to them. The only caveat, and unaware to the homework beggar, was that the answer used advanced techniques that no beginner would know of. The goal was to see if the beggar ran off with the advanced solution and handed it in to the teacher. Or sometimes, the code was obfuscated, but gave the correct output anyway. Commented Jul 13, 2021 at 5:20
  • 12
    I think part of the problem is the on-boarding process of new people - they don't know what the site is about, or the general standard of quality. They sign up, paste code, add half a sentence, and press post. Then they get rejected and think SO's filled with assholes. There should be an modal saying "before you post, have you read How to Ask?" before the first question. SO is supposed to be a repository of Q&As, that's why we're flagging questions as duplicates: no question should be asked twice. So care needs to be taken when asking your question. I think many newbies don't know any of this.
    – Nearoo
    Commented Nov 12, 2021 at 18:04
  • 4
    I think that the best way to address a homework question is: if the OP provided code and wrote a good question just answer it as you normally would, if he just asked how to solve something don't give them a single line of code, try to describe the steps he should take in an easy and comprehensible way and to point him in the right direction so that he understands what he has to study or look for to accomplish the assignment. This would help the student definitely more than making his homework and more than downvoting the question into oblivion.
    – Fabio R.
    Commented Dec 2, 2021 at 11:31
  • 2
    @Nearoo I think that a similar modal would just get ignored, maybe a better feature would be a FAQ quiz before you can post your first question so that the user is forced to at least read them. Another idea could be to force new users (maybe based on rep) to compile a question template instead of the free box that we have now, so that new users can get used to the correct way of asking a question before letting them write whatever they want
    – Fabio R.
    Commented Dec 2, 2021 at 11:34
  • 3
    There is also a whole industry for paid homework (e.g., through Fiverr. Or more organised—they even say so directly—I quote: "You can submit your homework by simply clicking the 'Assignment submission' option and following the steps to submit your homework."). The creation of accounts and submitting the commissioned homework may even be automated by bots, etc. That is, the homework is submitted on the behalf of somebody else. This falls under academic dishonesty. Commented Apr 1, 2022 at 15:08
  • 5
    Accommodating such questions in their raw form incentivizes laziness and poor academic habits, and dilutes the worth of this forum. Let's not entirely do someone else's work for them. It is a different story if someone has made an effort to understand the concept(s) involved, and is asking a specific question or having a specific problem in regard to integrating the concept(s) into their solution. Making such an effort would most often lead to a post that doesn't look like a homework question in the first place. We need to flag and close questions that don't display any such effort.
    – Pat Jones
    Commented Apr 8, 2022 at 22:53
  • 3
    Here is (effectively) an admission that Stack Overflow is being used for paid homework (read the comment thread. And the linked questions). Commented May 6, 2022 at 9:21
  • Would it be worth adding a link to How to debug small programs by Eric Lippert to this answer?
    – wjandrea
    Commented Nov 10, 2023 at 15:30
  • 1
    @wjandrea While that link is a popular canonical resource, it is pretty specific to compiled languages. I have been thinking for a long time that something like this should exist for Python, PHP, etc.
    – tripleee
    Commented Nov 11, 2023 at 18:19
  • @tripleee Good point. When I've reviewed it myself WRT Python questions, in my head I've translated the concepts, like "your program actually compiles" to "your program doesn't have a syntax error" and "compiler warnings" to "interpreter warnings".
    – wjandrea
    Commented Nov 11, 2023 at 18:55
175

FWIW, I teach a programming class, and have the following policy:

Programming is a "team sport," and it is good for you to talk with each other about ideas on how to confront the problems, and look to the Internet and other sources for ideas.

Nevertheless, the work you hand in with your name on it should represent work that you did.

If you work with others to complete your lab, list those people with your source code. Also, if you get code from an online resource, list the URL with the lab, and credit where you got the code from. This is a common courtesy and a legal requirement, even for free, open-source software.

Failure to give credit is plagiarism. Work that is apparent plagiarism may receive little or no credit.

16
  • 48
    You should add a parenthetical: "(<I/Your grader> knows how to use google, too.)" After only a semester of grading Automata homework, it was really easy to separate the googlers from the people who actually did their homework.
    – Greg D
    Commented Oct 23, 2008 at 19:11
  • 25
    That's an incredibly lenient policy on plagiarism. My school had an automatic 'zero' for anything that included plagiarism and any cheating was reported to the dean of the college. On a second offense students could be removed from the program.
    – jsl4980
    Commented Oct 23, 2008 at 20:26
  • 9
    Well, where I am is further down in the academic chain such that we see the students as "customers."
    – JohnMcG
    Commented Oct 23, 2008 at 20:28
  • 2
    I agree with jsl4980, plagiarism should be handled aggressively (my college expelled students for the first offense. That said, I think having guidelines like this that make clear limits on what's in and what's out are very helpful for avoiding plagiarism in the first place.
    – acrosman
    Commented Oct 23, 2008 at 23:11
  • 7
    I have to agree with jsl4980. Now it did lead to some interesting problems, I inserted a quotation from SRV into one of my programs and cited it. This lead to my having to explain why I "stole" Java code from a guy who died before Java existed. Neither the prof nor the TA were from the US.
    – Dan Blair
    Commented Dec 3, 2008 at 15:58
  • 27
    I like your policy. Programming most certainly is a team sport. Commented Feb 9, 2009 at 4:25
  • wow, sbeen a while but still... yes on agressive plagiarism policies BUT how many different permutations of hello world can you make before stubling on someone else's, thus citing sources is NOT plagiarism.
    – Newtopian
    Commented Apr 15, 2009 at 7:07
  • This being said, students should sometimes be reminded that the homework was about programming, not net surfing thus even if all sources were cited the grades are on the actual work done towards that goal... That's how we did it when grading papers, it was well accepted by both students and staff
    – Newtopian
    Commented Apr 15, 2009 at 7:09
  • 3
    Yes, in a literature course, I can use resources, and quote them, and I must cite them and give proper credit. I share your viewpoint in that credit must be given, just as with any other resource. This seems like a guideline to impose on students.
    – Anonymous
    Commented Jun 19, 2009 at 6:50
  • 19
    I'm also a computer science professor, and this is similar to my policy as well. As long as they correctly cite something, they can use any source. That being said, if, after they've turned it in, there are so many citations or it's otherwise obvious that most of the work was done by others, I reserve the right to ask them to redo the project from scratch, using what they've learned, but not using so much help this time. It's usually obvious if they misuse this policy, especially if they have a lot of trouble with the same concept on the very next project. They can't hide it forever. :-)
    – eruciform
    Commented Jul 6, 2010 at 0:51
  • Every page on here says user contributions licensed under cc-wiki with attribution required. If you take something non-trivial from here and use it verbatim in your own work (whether as a student or otherwise) without attributing it correctly to the author and to SE then you would be in breach of that licence, would you not?
    – barrowc
    Commented Nov 13, 2011 at 1:28
  • I just included that comment verbatim in a paper I submitted so I guess we'll find out (;-)
    – JohnMcG
    Commented Nov 17, 2011 at 17:34
  • 2
    @jsl4980 note that there is a HUGE difference between plagiarism (claiming as your own) and attributed use of open source (non copyrighted) material. As described, this policy condemns the former and condones the latter. It shows no sign of leniency towards plagiarism (or are you saying "apparent plagiarism gets little to no credit") is too lenient?
    – Floris
    Commented May 22, 2014 at 13:43
  • It's not hard to tell the difference between a student that has leaned the concepts and one that hasn't. IMO, learning and integrity are the only things that truly matter and grading should be based on that. Students already struggle when they get into college and find that things aren't as structured for them as they were in high school. It frustrates me that so many college courses continue this unnecessary rigid structure that does them little favor in most industries. Commented Oct 7, 2022 at 21:32
  • (SRV == Stevie Ray Vaughan, apparently?)
    – tripleee
    Commented Oct 27, 2023 at 5:29
-5

summary:

When answering (if you choose to), make sure you include plenty of explanation in English, not just code. But don't hold back from going into interesting details or showing code just because of who asked the question for what reason. The point of SO is to answer questions for future readers, not just for the OP.

When voting, be generous to new users if they aren't specifically asking SO to do their homework for them. But when you find old bad questions (homework or not) definitely downvote them. So there's kind of a "grace period" for sort-of-ok homework questions that don't have much future value, in case people want to spend their time helping that one person.


One of SO's important goals is to be a repository of useful answers to useful questions.

Homework questions sometimes subvert that, especially debugging questions which often have little to no future value and just clutter up everyone's search results. When you're looking for a good way to do something, you don't want to find all the confused bad ways, and answers debugging them but still implementing the bad way. Keep that in mind when answering (or choosing not to answer) a homework question.

If there's anything interesting worth saying in answer to a question (including a nice way to code something), I'm going to put that in an answer. To be an answer to the question asked, you do also have to directly answer the question (including pointing out things wrong with the OP's implementation, or explaining exactly why their code behaves the way it does).

I do tend to include more conceptual explanation than I would otherwise when answering a homework question, because usually it's clear that missing concepts are the reason they needed to ask in the first place instead of just writing some code.

But if the OP didn't want a complete answer to their question, they shouldn't have asked on SO. If I think it's worth answering in the first place, I don't like leaving out details or suggestions that would be useful to future readers wondering about the same problem.

If you just want guidance (or you don't know where to start), ask your instructor or TA for help.


I'm not saying you must always include working code when answering. Explain in English what's wrong with the OP's code, and/or what they should be doing. Don't reward lazy questions (homework or not) with code dumps. But don't hold back from showing code only because the original asker of the question was doing a homework problem.

If there's an alternate much better way to do what the OP was attempting, I'd encourage mentioning it. Sometimes that's easiest and clearest with code.


Homework questions are often posted by new users that don't know how to ask good questions yet. They're also often asking about the same thing that's been asked a zillion times, but with a unique misunderstanding or bug in their code.

I usually resist downvoting new questions like that, even though they have near-zero future value, as long as they include a [mcve] (if it's a debugging question). I will go looking for a duplicate to close it if possible, though (with an answer that explains things in English, not just a code dump, of course.)

But when I come across old questions like that (near-zero future value, with a problem that could have been found easily with a debugger), I downvote ruthlessly. I have no patience for old bad questions wasting my time in search results if they won't ever make good duplicate targets because they have two or three misunderstandings combined with various bugs.

For example, there are a zillion questions about printing or reading integers in x86 assembly language (usually 16-bit DOS because some schools are still teaching that??), and most of them are conceptual (multi-digit integers can't be handled as easily as single-digit ASCII) combined with debugging questions, so they aren't all duplicates.

(Using a debugger is more important in assembly language than in higher-level languages, because many totally wrong things are not build-time errors or warnings. Watching register values change as you single-step would reveal the bug in more than half the asm-homework questions that get asked.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .