This PR adds a new exponent operation to the calculator program. It includes the implementation of a new function named 'exponent' that calculates the result of a base raised to the power of an exponent. Error handling is also added to check for a zero base and a negative exponent, raising a ValueError with an appropriate error message.
Summary of Changes
Added a new function named 'exponent' to the calculator program.
The 'exponent' function takes two arguments, 'base' and 'exponent', and returns the result of 'base' raised to the power of 'exponent'.
Error handling is implemented in the 'exponent' function to check for a zero base and a negative exponent, raising a ValueError with an appropriate error message.
Modified the 'calculator' function to include the new 'Exponent' operation.
Added a new print statement to display the 'Exponent' operation option.
Added a new elif statement to handle the 'Exponent' operation in the 'calculator' function.
In the 'elif' statement, called the 'exponent' function with 'num1' and 'num2' as arguments, assigned the result to a variable named 'result', and printed the result in the same format as the other operations.
Added a try-except block to catch the ValueError raised by the 'exponent' function. If an error is caught, the error message is printed.
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_2
🎉 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 exponent operation to the calculator program. It includes the implementation of a new function named 'exponent' that calculates the result of a base raised to the power of an exponent. Error handling is also added to check for a zero base and a negative exponent, raising a ValueError with an appropriate error message.
Summary of Changes
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: