Skip to content

Commit c69bce5

Browse files
committed
remove unnecessary type conversion
This removes the ```float()``` around a (potential) integer division. Since Python3 the result of an integer division is a floating point number. This also removes the time and attention capacity necessary by learners for an explaination of what this does and why it is there. I do not mean to say that type conversions cannot be important, but the focus of this excercise is elsewhere. Note: it was good to have this in place for Python2, but Python2 is dead today and has been for a while. We also require an installation of Python3 in the setup.
1 parent 6f44f71 commit c69bce5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

_episodes/10-defensive.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ def normalize_rectangle(rect):
130130
dx = x1 - x0
131131
dy = y1 - y0
132132
if dx > dy:
133-
scaled = float(dx) / dy
133+
scaled = dx / dy
134134
upper_x, upper_y = 1.0, scaled
135135
else:
136-
scaled = float(dx) / dy
136+
scaled = dx / dy
137137
upper_x, upper_y = scaled, 1.0
138138
139139
assert 0 < upper_x <= 1.0, 'Calculated upper X coordinate invalid'

0 commit comments

Comments
 (0)