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
in 2000, Jonesville had a population of 15,000. in 2001, the population was 16250 and in 2002, the population was 17,500. if the
lesya [120]
Population (p) = 1,250n + 15,000
8 0
3 years ago
Read 2 more answers
A picture frame can hold a photograph that is 16 inches long and 12 inches wide. What is the area of the photo that fits the fra
velikii [3]
The answer is 192 square inches
8 0
3 years ago
Read 2 more answers
There were 375 students who said they rode the bus. This number represents 60% of the school enrollment. How many student are en
SVETLANKA909090 [29]
You would do 375 divided by 60% and get 6.25 if need to round to nearest whole it would be 6
5 0
3 years ago
Read 2 more answers
Why is estimating products of fractions useful
iren [92.7K]
This is useful so that you can come up with a quick answer rather then sit down with paper to solve the whole problem.
5 0
3 years ago
Brookton Brothers Supermarket sells 12 apples for $3.00. Kramer's Supermarket sells 18 apples for $4.00. Which store has the bet
otez555 [7]

Answer:

C

Step-by-step explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • Will mark as brainliest if correct
    14·1 answer
  • Which polygons can be mapped onto each other by similarity transformations?
    13·2 answers
  • To increase an amount by 3%, what single multiplier would you use??
    8·1 answer
  • Which system has no solutions?
    5·1 answer
  • Barry has $30.00. He spends $9.00 for lunch. Puzzle
    6·2 answers
  • Is x÷9=-4 an expression or equation
    11·2 answers
  • A spinner is divided into eight equal parts numbered 1 to 8. If the spinner spun once, what is the probability that it stops on
    5·2 answers
  • Which quadrant would the ordered pair (-10, 8) be located in?
    12·1 answer
  • Lauren took her cat Tommy to the veterinarian, who said
    11·1 answer
  • I want pictures of how you did it on paper!
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!