1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aliya0001 [1]
3 years ago
13

Complete the function digits(n) that returns how many digits the number has. For example: 25 has 2 digits and 144 has 3 digits

Mathematics
1 answer:
ss7ja [257]3 years ago
3 0

Answer:

Step-by-step explanation:

We can get this done by using the code

def digits(n):

count = 0

if n == 0:

return 1

while (n > 0):

count += 1

n= n//10

return count

Also, another way of putting it is by saying

def digits(n):

return len(str(n))

------------------------------------------

print(digits(25)) # Should print 2

print(digits(144)) # Should print 3

print(digits(1000)) # Should print 4

print(digits(0)) # Should print 1

Doing this way, we've told the system to count the number of figures that exist in the number. If it's 1000 to 9999, then it records it as 4 digits. If it's 100 - 999, then it records it as 3 digits. If it's 10 - 99, it records as 2 digits. If it's 0 - 9, then it has to record it as a single digit.

Thanks

You might be interested in
Hiii! does anyone stan nct? if so what's your favorite unit and bias? :D
romanna [79]

Answer:

i not a nctzen yet but i want to be!

Step-by-step explanation:

i am a multistan but there are just too many handsomeness in nct that i cant even keep track of

right now im just trying my best to learn some of their names which i cant even remember lol  

8 0
3 years ago
Read 2 more answers
The population of a city is 50,000. It is increasing at an annual rate of 3%. What is the
vlada-n [284]
The population will be 56,275 people.
You can see the picture for the formula.

3 0
3 years ago
Read 2 more answers
Write 1.67% as a decimal. thx :)
Bas_tet [7]

Answer:

0.0167

Step-by-step explanation:

divide by 100

6 0
3 years ago
Read 2 more answers
The quotient of 100 and the quantity of 6+ Y
Butoxors [25]
The answer is: 100/(6+y)
you can ignore these words, its that 20 character thing
8 0
3 years ago
Find the slope and the y−intercept of the line in the graph.
s344n2d4d5 [400]

Answer:

slope = 3/1 or just 3

y intercept = (0, 5)

Step-by-step explanation:

5 0
3 years ago
Other questions:
  • A number x is at least -10.<br><br> Twice a number y is more than 5/2
    9·1 answer
  • The sophomore class sold a total of 700 adult and student tickets to the school play. Adult tickets sold for $4.50 each and stud
    13·2 answers
  • What is the domain of F(x)=1/x
    8·1 answer
  • HELP Apex need fast please!!
    7·1 answer
  • Given h(x) = -x + 5, find h(5).
    13·2 answers
  • Helppp! Please! thank you!!!!!!
    6·1 answer
  • Solve the equation.<br><br> y + 3 = –y + 9<br><br> y = 1<br> y = 3<br> y = 6<br> y = 9
    7·2 answers
  • HELP PLEASE GUYS I WILL MARK YOU AS BRAINIEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    13·2 answers
  • Please help me if you can thank you.
    13·1 answer
  • Please help i will give brainly to answer that helps
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!