X Tutup
The Wayback Machine - https://web.archive.org/web/20201125011918/https://github.com/TheAlgorithms/Python/pull/3934
Skip to content
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

New algorithm added #3934

Open
wants to merge 16 commits into
base: master
from
Open

New algorithm added #3934

wants to merge 16 commits into from

Conversation

@erdum
Copy link

@erdum erdum commented Nov 22, 2020

Describe your change:

Finnaly i did it now i hope all checks should be clear

  • 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 have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
@erdum

This comment has been minimized.

Copy link
Owner Author

@erdum erdum commented on 3986d64 Nov 22, 2020

I have work a lot on this file and again make new Pr this time i follow all the guidelines styling conventions now lets see what will happen??

erdum added 7 commits Nov 22, 2020
@erdum
Copy link
Author

@erdum erdum commented Nov 22, 2020

Thank god i made my first ever github contribution, i was very difficult for a beginner, but i did it, jus please review it and merged it i will more happy if you will merged it thanks.

Co-authored-by: xcodz-dot <71920621+xcodz-dot@users.noreply.github.com>
@erdum erdum mentioned this pull request Nov 23, 2020
electronics/ohms_law.py Outdated Show resolved Hide resolved
electronics/ohms_law.py Outdated Show resolved Hide resolved
electronics/ohms_law.py Show resolved Hide resolved
result = float(current * resistance)
return result
Comment on lines 19 to 20

This comment has been minimized.

@cclauss

cclauss Nov 24, 2020
Member

I think your function should return a dict or even better a namedtuple which provides both the name of the value and the value itself.

Creating result on one line and getting rid of it on the next is not helpful.

Suggested change
result = float(current * resistance)
return result
return {"voltage": float(current * resistance)}
>>> ohms_law(voltage=10, resistance=5,current=0 )
2.0
>>> ohms_law(current=1, resistance=10, voltage=0)
10.0

This comment has been minimized.

@cclauss

cclauss Nov 24, 2020
Member

Test for numbers with fractional parts (1.5) and negative numbers, etc.

This comment has been minimized.

@erdum

erdum Nov 24, 2020
Author

No problem i will be right back

erdum and others added 3 commits Nov 24, 2020
Co-authored-by: Christian Clauss <cclauss@me.com>
@erdum
Copy link
Author

@erdum erdum commented Nov 24, 2020

But cclauss thank you so much showing interest in my code before you nobody even tell me the problems with my code thank you again and i will be add these changes as you tell me .

@erdum
Copy link
Author

@erdum erdum commented Nov 24, 2020

So i got it what you suggest me is

  1. return dictionary with value name instead value
  2. doctest import is made inside main
  3. Comments should be helpful for reader
  4. And for wrong value input value error should be raised instead returning 0
@erdum
Copy link
Author

@erdum erdum commented Nov 24, 2020

cclauss i did it finally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.
X Tutup