Skip to content

conversions/decimal_to_binary.py: Add type hints#2001

Merged
cclauss merged 4 commits intoTheAlgorithms:masterfrom
sarcastic-verma:add-type-hints
Jun 2, 2020
Merged

conversions/decimal_to_binary.py: Add type hints#2001
cclauss merged 4 commits intoTheAlgorithms:masterfrom
sarcastic-verma:add-type-hints

Conversation

@sarcastic-verma
Copy link
Copy Markdown
Contributor

@sarcastic-verma sarcastic-verma commented May 18, 2020

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 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}.

@cclauss cclauss changed the title Add type hints conversions/decimal_to_binary.py: Add type hints May 18, 2020


def decimal_to_binary(num):
def decimal_to_binary(num: int) -> str:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It might be even cooler to actually return a binary number. i.e. 0b123 instead of "0b123".

@cclauss cclauss merged commit d7cc778 into TheAlgorithms:master Jun 2, 2020
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* A .py file to covert a base to any new base(2-18)

* Update base_changer.py

* Added type-hints.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants