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]
2 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]2 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
Six of King Arthur’s knights are sitting around the Round Table eating peanuts. Since each knight suspected the others of not sh
Bogdan [553]

Answer:

You must add the numbers of the neigbors from the one who counted 52, subtract the number of the one who is opposide and divided by 2.

So i calculate

(44 + 60 - 28) = 38

The knight who counted 52 has 38 peanuts.

5 0
3 years ago
Read 2 more answers
Multiply.<br> (5v+6w-7)(-3)<br> Simplify your answer.
Zielflug [23.3K]

Answer:

if my calculator is not wrong Is 21

3 0
2 years ago
The coordinates of a point on a coordinate grid are (−2, 6). The point is reflected across the x-axis to obtain a new point. The
Juliette [100K]
The reflected coordinate will be (-2,-6)
3 0
3 years ago
Read 2 more answers
Question 1-6
Mumz [18]

i mean ig but 129.... ehh

3 0
2 years ago
Read 2 more answers
a fish tank has a height of 30 inches, length of 20 inches, and a width of w 25 inches. how many cubic inches will the tank hold
dexar [7]

Answer:

Here is your answer!

Step-by-step explanation:

6 0
3 years ago
Other questions:
  • Which student evaluated the power correctly?
    9·2 answers
  • What is x 35x+10=190
    7·2 answers
  • in an equation y varies directly as x varies. if y = 55 when x = 22, what is the value of x when y = 85?​
    12·1 answer
  • Use the product property for radicals to simplify the following radical expressions as much as possible. Square root of 54
    8·1 answer
  • Help what is the answer
    9·1 answer
  • M: Mental
    13·2 answers
  • What is 2.97239915 rounded to the nearest ten?
    14·2 answers
  • What is 1 over 2 multiplied by 1 over 5?
    6·2 answers
  • I need the answer. Thank you
    13·1 answer
  • What is 2/4 x 3/5 = 3.14
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!