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
What is the y-intercept in the equation y = 4x-3?​
timofeeve [1]

Answer:

-3

Step-by-step explanation:

y = mx + b

b is the y-intercept

5 0
2 years ago
Read 2 more answers
Write an equation<br> write an solution<br> and do a check step
melomori [17]

what is one easy addition equation?

1 + 1 = 2

how did you get this ?

you add 1 and 1 together and you will get your solution.

7 0
2 years ago
On a certain game show, contestants pick 5 number balls from a bag containing 20 numbered balls (0-19). After each draw, the bal
Gnoma [55]

Answer:

5/20 or 25% probability of winning $1,000,000

Step-by-step explanation:

How many numbered balls do they need to win?

5

How many balls are there?

20

Therefor your answer is (balls need to win/number of balls).

4 0
1 year ago
Are the two triangles similar?
Tpy6a [65]

Answer:

Option B Yes by AAA

Step-by-step explanation:

we know that

If the two triangles are similar, then the ratio of its corresponding sides is equal and its corresponding angles are congruent

so

\frac{HM}{MK}=\frac{GM}{MJ}

substitute the values and verify

\frac{8}{12}=\frac{6}{9}

simplify

\frac{2}{3}=\frac{2}{3} -------> is true

therefore

The triangles are similar by AAA------> the three angles are congruent

4 0
3 years ago
1. What is the surface area of the cube
Marrrta [24]

Answer:

96 in. squared

Step-by-step explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • Y and x vary directly. If the constant of variation is 1/2, then what is the value of y when x= -6
    15·1 answer
  • if I have a binomial distribution where n equals 8 trials and a probability of success equals 0.40 what is the successes of X is
    7·1 answer
  • What is the solution of 3+ x-2/x-3&lt;_4
    11·1 answer
  • 6 radians is the same as ____°.<br> Round to the nearest hundredth of a degree.
    7·2 answers
  • Determine the intercepts of the line.<br> 3x + 2y = 5<br> y-intercept:<br> X-intercept:
    9·2 answers
  • The area of the sector formed by the 110 degree central angle is 50 units squared. What is the circumference of the circle
    15·1 answer
  • Is the following statement true or false?
    9·1 answer
  • 1. The average police office writes 40 tickets each week (with a standard deviation of 12). If the number of tickets a police of
    6·1 answer
  • Hi can you please help me ​
    7·2 answers
  • (9^6 * 7^-9)^-4.<br> Thanks!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!