Too many decision blocks were found, which is why the code has been tagged as complex. You should consider refactoring the code for simplicity. Read more about cyclomatic complexity here.
Calculating the length of the hypotenuse using the standard formula
c = sqrt(a**2 + b**2) may lead to overflow if the two other sides are both very large. Even though
c will not be much bigger than
max(a, b), either
b**2 (or both) could be. Thus, the calculation could overflow, even though the result is well within representable range. It is recommended to use the built-in function
hypot(a,b) from the
The boolean expression with redundant pre-python 2.5 ternary syntax is used and can be simplified for better readability. Please look at the issue text for suggestion.
Opening a file using
with statement is preferred as function
open implements the context manager protocol that releases the resource when it is outside of the
with block. Not doing so requires you to manually release the resource.
The preferred way to iterate over the key-value pairs of a dictionary is to declare two variables in a for loop, and then call
dictionary.iteritems() for Python2), where dictionary is the name of your variable representing a dictionary.'