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

Create number_of_digits.py #1975

Open
wants to merge 4 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -11,7 +11,7 @@ class NearestNeighbour:

def __init__(self, img, dst_width: int, dst_height: int):
if dst_width < 0 or dst_height < 0:
raise ValueError(f"Destination width/height should be > 0")
raise ValueError("Destination width/height should be > 0")

self.img = img
self.src_w = img.shape[1]
@@ -0,0 +1,18 @@
def num_digits(n):
"""
Find the number of digits in a number.
>>> num_digits(12345)
5
>>> num_digits(123)
3
"""
digits = 0
while(n > 0):
n = n // 10
digits = digits + 1
return digits


if __name__ == "__main__":
num = 12345
print(num_digits(num)) # ===> 5
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.