This is not a post about praising or bashing either language, but rather an objective account of the differences I discovered myself while working through the Invent With Python book. These seem interesting to me, so here goes:
 This is still a bit fuzzy to me, but in Python, variables are in scope even outside the loops in which they are first instantiated. True, we do not need to declare variables in Python, as opposed to C++, but intuitively I would still have thought that a variable won’t be visible or retain its value outside the loop it is first used in. However, as the screenshot shows, Python recognizes the variable r outside the for loop in the function and returns it. C++ however, throws a compile time error when it sees the code in the corresponding screenshot.
 In Python a function may accept an argument of any type, and return a value of any type, without any kind of declaration beforehand. For example, in the screenshot, you see the function might accept a boolean and return a boolean, or it might accept an integer and return a string or vice versa. Even though Python is strongly typed in a sense that you may not add a string and an integer without an explicit conversion. For example in Perl, something like this is valid:
my $a = “A”;
my $b = 3;
my $c = $a.$b;
And it produces the result A3. However, you may not do the following in Python:
>>> a = ‘a’
>>> b = 3
>>> c = a + b
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
TypeError: cannot concatenate ‘str’ and ‘int’ objects
Yet this kind of flexibility that Python provides in calling functions and returning values makes our code incredibly simple and much more maintainable. Perl provides something like that too but Python looks cleaner, is object oriented, and still maintains a little strictness about types. Again, this post is not about bashing a language or promoting another.
 The division of two integers in Python is always a float (in Python 3; or in Python 2 if you import division from __future__), as opposed to C++ where you need to do some casting to make that happen.
 The round function in Python always rounds intelligently – round(4.3) is 4 and round(4.9) is 5, and it even works for negative numbers. In C++ there’s no round function; there’s floor and ceil, but you need to know beforehand which one to use.