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
&gt;&gt;<br> What is the value of x that makes PQ|| RS?<br> plssss help. i need help bad
kirill [66]

Answer: 55

Step-by-step explanation:

By the alternate exterior angles theorem,

3x-65=2x-10\\x-65=-10\\x=55

5 0
1 year ago
A carton has a length of 2 2/3 feet, width of 1 1/3 feet, and a height of 1 1/2. What is the volume of the carton? A( 4 cubic fe
notsponge [240]

Answer:

The volume of the carton is 5 1/3 cubic feet

Step-by-step explanation:

A carton has a length of 2 2/3 feet, width of 1 1/3 feet, and a height of 1 1/2.

The dimensions can be rewritten as

Length of carton =2 2/3 = 8/3 converting to improper fraction).

width of 1 1/3 feet = 4/3 feet

and a height of 1 1/2= 3/2 ,feet

volume of the carton = length of the carton × width of the carton × height of the carton

Volume of carton = 8/3 ×4/3 × 3/2

= 96/18 cubic feet

Converting to mixed fractions, we have

96/18= 5 1/3 cubic feet

8 0
3 years ago
How can you classify a trapezoid in other terms?
Harrizon [31]
<span>The sections that it is in are Classifying Quadrilaterals Properties of Parallelograms Special Parallelograms Trapezoids and Kites Placing Figures in the Coordinate Plane</span>
8 0
3 years ago
I don’t understand lol
pogonyaev

Answer:

3*r = 3

Step-by-step explanation:

\dfrac{24}{r}=3\\\\24 = r*3\\\\\dfrac{24}{3}=r\\\\6 = r6 is a solution.

3*r=3\\\r =\dfrac{3}{3}\\\\r = 1\\

6 is not a solution.

7r = 42\\\\r =\dfrac{42}{7}\\\\r = 6

6 is a solution

8 0
2 years ago
Read 2 more answers
0 find the smallest values of n which will guarantee a theoretical error less than if the integral is estimated by: (a) the trap
goldenfox [79]

Answer:

Step-by-step explanation:

Check attachment for answers.

3 0
3 years ago
Read 2 more answers
Other questions:
  • A regular hexagon has an apothem measuring 14 cm and an approximate perimeter of 96 cm.
    12·2 answers
  • Which expression is equivalent to the expression shown? Need help
    10·1 answer
  • A carpenter makes legs for 3-legged stools and 4-legged tables. He makes a total of 57 legs. He could have made legs for how man
    5·2 answers
  • 6r - 7 over 10 = r over 4
    12·1 answer
  • Need help please thank you
    11·2 answers
  • Tim has an encyclopedia in 5 volumesA–C, D–F, G–J, K–N, and O–Z. Other than alphabetically (ascending or descending), how many w
    13·2 answers
  • How do you solve this equation log(3x+1)=5
    11·2 answers
  • Is -1/3 greater than -1/2?
    13·2 answers
  • A Cinema has 240 seats. 144 seats were sold for the current movie. What percent of seats were empty?
    8·1 answer
  • Pls I have been stuck for the LONGEST TIME I WILL GIVE BRAINLIEST​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!