close
The Wayback Machine - https://web.archive.org/web/20250516185528/https://github.com/TheAlgorithms/Python/pull/8155
Skip to content

Added algorithm for DC electric power formula #8155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

joseph-alan-jose
Copy link

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Feb 22, 2023
@@ -0,0 +1,60 @@
"""
Calculating Electric Power
Description : Electric power can be said to be the rate at which
Copy link
Contributor

Choose a reason for hiding this comment

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

The provided code calculates the electric power for DC circuits based on the given input parameters, which include the potential difference (voltage), current, and resistance.

You should change PR name as DC Electric Power formula.

Copy link
Author

Choose a reason for hiding this comment

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

Thankyou for the feedback

@joseph-alan-jose joseph-alan-jose changed the title Added algorithm for electric power formula Added algorithm for DC electric power formula Apr 25, 2023
Copy link
Contributor

@rohan472000 rohan472000 left a comment

Choose a reason for hiding this comment

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

change the function name to dc_power

Comment on lines +36 to +41
>>> power(potential_difference=5.0, current=6.0)
30.0
>>> power(current=2.0, resistance=5.0)
20.0
>>> power(potential_difference=4.0, resistance=2.0)
8.0
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
>>> power(potential_difference=5.0, current=6.0)
30.0
>>> power(current=2.0, resistance=5.0)
20.0
>>> power(potential_difference=4.0, resistance=2.0)
8.0
>>> dc_power(potential_difference=5.0, current=6.0)
30.0
>>> dc_power(current=2.0, resistance=5.0)
20.0
>>> dc_power(potential_difference=4.0, resistance=2.0)
8.0

"""


def power(**values: float) -> float:
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
def power(**values: float) -> float:
def dc_power(**values: float) -> float:

@stale
Copy link

stale bot commented Jun 18, 2023

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Jun 18, 2023
@tianyizheng02
Copy link
Contributor

Thanks for your contribution, but we already have an implementation of the electric power formula in electronics/electric_power.py. However, that implementation doesn't support calculating resistance, so you're free to build upon that implementation and extend its functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reviews This PR is ready to be reviewed stale Used to mark an issue or pull request stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants