Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion digital_image_processing/resize/resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
18 changes: 18 additions & 0 deletions maths/number_of_digits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def num_digits(n: int) -> int:
"""
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 += 1
return digits


if __name__ == "__main__":
print(num_digits(12345)) # ===> 5