TG Telegram Group & Channel
🇺🇦 Python Programming Сhallenges | United States America (US)
Create: Update:

Found very intersting approach to count the digits of an integers #python:

from math import floor, log10


def count_digits(n):
return 1 + floor(log10(n))

In [2]: count_digits(5)
Out[2]: 1

In [3]: count_digits(999)
Out[3]: 3

In [4]: count_digits(1000)
Out[4]: 4

Found very intersting approach to count the digits of an integers #python:

from math import floor, log10


def count_digits(n):
return 1 + floor(log10(n))

In [2]: count_digits(5)
Out[2]: 1

In [3]: count_digits(999)
Out[3]: 3

In [4]: count_digits(1000)
Out[4]: 4


>>Click here to continue<<

🇺🇦 Python Programming Сhallenges




Share with your best friend
VIEW MORE

United States America Popular Telegram Group (US)