lukejagg / test-canary

Miscellaneous files for ML + web development
0 stars 1 forks source link

Add new operation for computing the exponent #235

Closed ghost closed 1 year ago

ghost commented 1 year ago

Description

This PR adds a new operation for computing the exponent of two numbers (A^B) to the calculator program.

Summary

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

To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.

kevinlu1248 commented 1 year ago

sweep: regenerate calculator.py

kevinlu1248 commented 1 year ago

sweep: regenerate calculator.py

kevinlu1248 commented 1 year ago

sweep: regenerate calculator.py

kevinlu1248 commented 1 year ago

sweep: regenerate calculator.py

kevinlu1248 commented 1 year ago

sweep: regenerate calculator.py

kevinlu1248 commented 1 year ago

sweep: regenerate calculator.py

ghost commented 1 year ago

sweep: regenerate calculator.py

Hi @kevinlu1248,

I decided to make the following changes:

File Path Proposed Changes
calculator.py Modify calculator.py with contents:

> * Add a new function at the top of the file, after the divide function and before the calculator function. Name this function exponent, and make it take two arguments, base and exponent. In the body of the function, return the result of base raised to the power of exponent.
> • In the calculator function, add a new print statement after the print statement for the Divide operation, to display a new option for the Exponent operation.
> • After the if statement that handles the Divide operation, add a new elif statement to handle the Exponent operation. In this statement, call the exponent function with num1 and num2 as arguments, and assign the result to a variable named result. Then, print the result in the same format as the other operations.