Skip to content

Conversation

@jlozanopenagos
Copy link

Adding two new functions(% and log) in Calculadora.py and Calculador.py:

  1. Button Creation and Layout:
  • Two new buttons, labeled "log" and "%", have been added to the calculator interface.
  • These buttons are created with the appropriate text and styling to represent the logarithm and percentage operations.
  1. Event Handling:
  • Event handlers have been defined for the new buttons to capture user input and perform the corresponding operations.
  • The command attribute of the buttons is set to call specific methods when clicked.
  1. Expression Processing:
  • A new method _process_expression has been implemented to handle the processing of mathematical expressions containing the logarithm and percentage operations.
  • Within this method, the presence of the logarithm operation is detected, and if found, the logarithm function is evaluated and replaced with its result in the expression.
  • Error handling is included to deal with invalid arguments or operations, ensuring the stability of the calculator.
  1. Result Display:
  • The method _set_result_in_input has been updated to handle the display of results for expressions containing logarithms and percentages.
  • If an error occurs during evaluation, such as an invalid operation or division by zero, the method displays an appropriate error message.
  1. User Interface Interaction:
  • Users can now input logarithmic expressions by clicking the "log" button, followed by the number or expression inside parentheses. It can be use with others operations
  • Similarly, the "%" button allows users to input percentage calculations, which are then processed accordingly.

@GiwbyAlbatross
Copy link

It looks like the % simply uses python’s builtin % operator, which is not in fact percent, but rather it is modulus, showing the remainder of a division operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants