This PR adds a new operation for computing the exponent to the existing calculator program. The new operation allows the user to calculate the result of raising a base number to the power of an exponent.
Summary of Changes
Added a new function named exponent to the calculator.py file. This function takes two arguments, base and exponent, and returns the result of base raised to the power of exponent. Error handling is implemented to raise a ValueError with the message "Cannot divide by zero!" if the base is zero and the exponent is negative.
Modified the calculator function in the calculator.py file to include the new operation in the user interface.
Added a new print statement to display the option for the Exponent operation.
Added a new elif statement to handle the Exponent operation when the user selects it. The exponent function is called with num1 and num2 as arguments, and the result is printed in the same format as the other operations.
Added a try-except block in the elif statement for the Exponent operation to catch the ValueError raised by the exponent function. If an error is caught, the error message is printed and the next iteration of the loop is continued.
Please review and merge this PR. Thank you!
Fixes #1.
To checkout this PR branch, run the following command in your terminal:
git checkout sweep/add-exponent-operation_3
🎉 Latest improvements to Sweep:
Use Sweep Map to break large issues into smaller sub-issues, perfect for large tasks like "Sweep (map): migrate from React class components to function components"
Getting Sweep to format before committing! Check out Sweep Sandbox Configs to set it up.
We released a demo of our chunker, where you can find the corresponding blog and code.
💡 To get Sweep to edit this pull request, you can:
Leave a comment below to get Sweep to edit the entire PR
Leave a comment in the code will only modify the file
Edit the original issue to get Sweep to recreate the PR from scratch
Description
This PR adds a new operation for computing the exponent to the existing calculator program. The new operation allows the user to calculate the result of raising a base number to the power of an exponent.
Summary of Changes
exponent
to thecalculator.py
file. This function takes two arguments,base
andexponent
, and returns the result ofbase
raised to the power ofexponent
. Error handling is implemented to raise aValueError
with the message "Cannot divide by zero!" if the base is zero and the exponent is negative.calculator
function in thecalculator.py
file to include the new operation in the user interface.Exponent
operation.elif
statement to handle theExponent
operation when the user selects it. Theexponent
function is called withnum1
andnum2
as arguments, and the result is printed in the same format as the other operations.elif
statement for theExponent
operation to catch theValueError
raised by theexponent
function. If an error is caught, the error message is printed and the next iteration of the loop is continued.Please review and merge this PR. Thank you!
Fixes #1.
To checkout this PR branch, run the following command in your terminal:
🎉 Latest improvements to Sweep:
💡 To get Sweep to edit this pull request, you can: