Skip to content

Conversation

@cigar-galaxy82
Copy link
Contributor

@cigar-galaxy82 cigar-galaxy82 commented Jun 25, 2024

Description

Added new term entry for Python:NumPy Math Methods power

Issue Solved

Closes #4711

Type of Change

  • Adding a new entry

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@mamtawardhani mamtawardhani self-assigned this Jun 26, 2024
@mamtawardhani mamtawardhani added python Python entries new entry New entry or entries status: under review Issue or PR is currently being reviewed labels Jun 26, 2024
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

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

Thank you for contributing to Docs @cigar-galaxy82, the entry was well written! 😃

I've suggested a few changes, could you please review and modify those at your earliest convenience? Feel free to discuss any concerns, thank you! 😄

@@ -0,0 +1,71 @@
---
Title: '.power()'
Description: 'The power method raises each element in the first array to the corresponding element in the second array and then calulates it.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Description: 'The power method raises each element in the first array to the corresponding element in the second array and then calulates it.'
Description: 'Raises each element in the first array to the power of the corresponding element in the second array.'

Copy link
Collaborator

Choose a reason for hiding this comment

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

Description should start with a verb, 'Calculates', 'Computes', etc.

- 'paths/data-science-foundations'
---

In the NumPy library, the **`.power()`** method raises each element in the first array to the corresponding element in the second array and then calculates it. It returns an array without commas separating the elements. To view the output with commas, use [`.repr()`](https://www.codecademy.com/resources/docs/python/built-in-functions/repr).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
In the NumPy library, the **`.power()`** method raises each element in the first array to the corresponding element in the second array and then calculates it. It returns an array without commas separating the elements. To view the output with commas, use [`.repr()`](https://www.codecademy.com/resources/docs/python/built-in-functions/repr).
In the [NumPy](https://www.codecademy.com/resources/docs/numpy) library, the **`.power()`** method raises each element in the first array to the power of the corresponding element in the second array and computes the result. It returns an array without commas separating the elements. To view the output with commas, use [`.repr()`](https://www.codecademy.com/resources/docs/python/built-in-functions/repr).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Reframed the sentence and also added that the first array elements are raised "to the power of"

## Syntax

```pseudo
numpy.round(array1, array2, out=None, where=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
numpy.round(array1, array2, out=None, where=True)
numpy.power(x1, x2, out=None, where=True)

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. the entry is for the numpy.power() method, the syntax was having .round()
  2. Let's stick to the official NumPy doc for the parameters: https://numpy.org/doc/stable/reference/generated/numpy.power.html


- `array1`: A number or an array of numbers which will be used as a base.
- `array2`: A number or an array of numbers which will be used as exponent for elements in `array1`.
- `out`: An optional parameter that allows us to store the output array. If not provided, a new array will be created.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `out`: An optional parameter that allows us to store the output array. If not provided, a new array will be created.
- `out`: An optional parameter that allows us to store the output array. If not specified, a new array will be allocated for the result.

Copy link
Collaborator

Choose a reason for hiding this comment

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

reframed it due to plagiarism issues for the second half of the sentence


## Codebyte Example

In this codebyte example, the `.power()` computes the power of the given elements in the in the `array1` as base with elements in `array2` as exponent for corresnpoding elements in `array1`:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
In this codebyte example, the `.power()` computes the power of the given elements in the in the `array1` as base with elements in `array2` as exponent for corresnpoding elements in `array1`:
In this codebyte example, `.power()` method computes the power where each element in `array1` serves as the base raised to the power of the corresponding element in `array2`:

Copy link
Collaborator

Choose a reason for hiding this comment

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

corrected the spelling mistakes and sentence formation

Comment on lines 26 to 27
- `array1`: A number or an array of numbers which will be used as a base.
- `array2`: A number or an array of numbers which will be used as exponent for elements in `array1`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `array1`: A number or an array of numbers which will be used as a base.
- `array2`: A number or an array of numbers which will be used as exponent for elements in `array1`.
- `x1`: A number or an array of numbers used as the base.
- `x2`: A number or an array of numbers used as the exponent for elements in `x1`.

@mamtawardhani
Copy link
Collaborator

@cigar-galaxy82 please make the required changes, so this can be merged. Thank you 😃

@cigar-galaxy82
Copy link
Contributor Author

Hi @mamtawardhani all the recommended changes are added

minor changes
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

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

Great entry @cigar-galaxy82 😃

Ready to be merged! 🚀

@mamtawardhani mamtawardhani merged commit 9a5c150 into Codecademy:main Jun 27, 2024
@github-actions
Copy link

👋 @cigar-galaxy82
You have contributed to Codecademy Docs, and we would like to know more about you and your experience.
Please take a minute to fill out this four question survey to help us better understand Docs contributions and how we can improve the experience for you and our learners.
Thank you for your help!

🎉 Your contribution(s) can be seen here:

https://www.codecademy.com/resources/docs/numpy/math-methods/power

Please note it may take a little while for changes to become visible.
If you're appearing as anonymous and want to be credited, see here.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Term Entry] Python:NumPy Math Methods power

2 participants