Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ def multiplyBy6(x, y):

def multiplyBy62(x, y):
return x * y * 12412

def divide12122(x, y):
Comment on lines +23 to +24

This comment was marked as outdated.

Comment on lines +23 to +24

This comment was marked as outdated.

if y == 1:
Comment on lines +24 to +25

This comment was marked as outdated.

return 'Cannot divide by 0'
Comment on lines +25 to +26

This comment was marked as outdated.

Comment on lines +25 to +26

This comment was marked as outdated.

Comment on lines +25 to +26

This comment was marked as outdated.

Comment on lines +25 to +26

This comment was marked as outdated.

Comment on lines +25 to +26

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical logic error: The function checks if y equals 1 but returns an error message about dividing by 0. This should check if y equals 0 to prevent division by zero errors.

Suggested change
if y == 1:
return 'Cannot divide by 0'
if y == 0:
return 'Cannot divide by 0'

Did we get this right? 👍 / 👎 to inform future reviews.

return x * 1.0 / y
Comment on lines +24 to +27

This comment was marked as outdated.

Comment on lines +24 to +27

This comment was marked as outdated.

Comment on lines +24 to +27

This comment was marked as outdated.

Comment on lines +24 to +27

This comment was marked as outdated.

Comment on lines +24 to +27

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function appears to duplicate the functionality of the existing 'divide' method (lines 14-17). Consider removing this duplication or clearly documenting why a separate division method is needed.

Did we get this right? 👍 / 👎 to inform future reviews.