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
ITSSS A QUIZ PLSSSSSSSS HELP ME
FinnZ [79.3K]

Answer:

X=80

Step-by-step explanation:

180-100=80

8 0
4 years ago
Read 2 more answers
Write a expression that shows how to multiply 4 x 362 using place value and expanded form??
dexar [7]

Answer:


Step-by-step explanation:


3 0
3 years ago
The chart shows a sample paycheck stub.Salary1106.45Federal122.67Income TaxSocial Security68.60TaxMedicare Tax16.04State Income1
vladimir1956 [14]
Federal and state taxes are withheld from employee pay
8 0
4 years ago
Read 2 more answers
chris's hike started at an elevation of -12 m. His hike finished at an elevation of 235 m. How much did chris's elevation change
Ivan
235-(-12)=247; his elevation changed by 247 m. 
3 0
4 years ago
Which equation is equivalent to 23x= 10?
vovangra [49]
That answer would be d
cause I’m big brain
4 0
3 years ago
Other questions:
  • 70 Points!! Question!​
    7·2 answers
  • What is the retirement fund for a Dental Assistant?
    10·2 answers
  • The school store is selling student planners. It costs $2 each week to advertise the planners. The store buys each planner for $
    10·2 answers
  • What is the inverse of the function f(x) =2x +1?
    15·1 answer
  • Which is not a good model of 3 divided by 1/4HELP
    6·2 answers
  • Viktoriya solved an equation as shown below. 5 (x minus 2) minus 3 x = 2 (x minus 3) minus 16. 5 x minus 10 minus 3 x = 2 x minu
    7·2 answers
  • Help no good at maths
    9·1 answer
  • What number must you add to complete the square? x^2+26x=33
    10·1 answer
  • Eggs flour and sugar are mixed in the ratio of 3: 5: 4 by mass to make a cake. If the mass of the sugar is 240g find the mass of
    6·1 answer
  • Need help with this please
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!