Interview questions can be tricky.
Coming up with a decent answer in a highly stressful environment of a technical interview might prove to be a real challenge. That’s why preparation is necessary to land that dream internship!
Today we will dive into an answer to a very common interview question.
In your opinion, what is the biggest difference between C++ and Python?
This article is not meant to be a complete list of all differences between the two. It’s simply a draft of an answer with enough details to satisfy an interviewer asking this question.
Arguably, the biggest difference between the two is the type system. C++ is a statistically typed language. This means that a type of a variable has to be defined when the variable is declared and cannot be changed later. On contrary, Python is dynamically typed, which means that you’re free to change the type of variable if you wish to do so.
id = str(id) is perfectly valid Python. Convenient, huh?
C++ is a compiled language. Python code is first compiled to byte code (those .pyc files you probably seen). This byte code is then executed by a Python virtual machine.
In contrary to C+, Python does not support pointers, nor pointer arithmetic. You can read more about pointers and references in C++/Python here.
In C++ it’s programmers responsibility to allocate and deallocate memory. Python completely abstracts memory management from the programmer.
For the interviewer, it’s probably going to be the least interesting part of the answer, but the syntax of both languages is very different as well.