These sorts of open-ended questions don't have a "correct" answer, and I am surprised the interviewer told you directly that your answer was incorrect. It's possible the interviewer was unqualified to ask the question, or just had little experience interviewing candidates.
If I had asked that question and gotten your answers, I would have probed a bit deeper, saying "Yes, they are typically used in different ways, but how do the languages differ?" Then I would have hoped to hear about the differences in OO support (JavaScript prototypes vs. Python inheritance), functional programming support, etc.
Still, in my opinion, none your statements:
- You can do system level programming with Python but not with Javascript
- You can compile Python but not Javascript
- Javascript can be used for formatting webpages, but Python cannot
are correct:
- You can do system-level programming in Javascript (see node.js)
- Any language can be compiled. Just because you don't have to invoke a compiler
to run Javascript doesn't mean it can't be compiled.
- Python could be used for formatting webpages, and often is on the server side. Python could also run on the client side; there is a Python compiler that produces Javascript.
I ask these sorts of questions to see how deeply the candidate has thought about the programming process. I prefer candidates with well-reasoned opinions about the technologies they have used. If a candidate has used two languages extensively, I would expect them to be able to discuss their likes and dislikes to some depth. Otherwise I conclude that the candidate has only a superficial understanding of the languages, and has mostly been programming at the search-and-paste level.
BTW, memorizing better answers to this question won't help you much in future interviews at similar companies. Interviewers use these open-ended questions to evoke a technical discussion. If you had given more correct answers, the interviewer would probably have followed up asking for more detail. If you express a preference for Python over Javascript or vice versa, a good interviewer will ask you to explain and defend your preference.