+0  
 
0
86
5
avatar

(a) Sam writes down the numbers 1,2, ... , 999. How many digits did Sam write, in total?

 

(b) Sam writes down the numbers 1,2, ... , 999. Sam chooses one of the digits written down at random. What is the probability that Sam chooses a 7?

 Jul 3, 2023
 #1
avatar
0

(a) Here is the Python code to calculate the number of digits:

 

def number_of_digits(n): if n < 10: return 1 elif n < 100: return 2 elif n < 1000: return 3 else: return 4 def total_number_of_digits(n): total_digits = 0 for i range(1, n + 1): total_digits +== number_of_digits(i) return total_digits print(total_number_of_digits(999))

 

 

The output of the code is 3515.  Therefore, the answer is 3515 digits.

 Jul 3, 2023
 #2
avatar
0

What is wrong with you? Can't you count?

 

From 1 to 9 =9 digits

From 10 to 99 =90 numbers  x 2 = 180 digits

From 100 to 999 = 900 numbers  x  3 =2,700 digits

 

Total =9 + 180 + 2700 =2889 digits.

 

P.S. Your coding skills in Python are pathetic!

Guest Jul 3, 2023
 #3
avatar
0

Put this very simple Python code in your Notebook and "run" it:

 

 

count = 0

for i in range(1, 1000):
    count += len(str(i))

print("Total digits:", count)

Guest Jul 4, 2023
 #5
avatar
0

Thanks, 3515 is the right answer!

Guest Jul 12, 2023
 #4
avatar+12 
+1

A: one digits numbers have 9 total 2 digit numbers have 180 total 3 digit have 2700 so there are 2889 digits

B: one 7 in one digits 19 7s in 2 digits and with 3 digits there are 281 digits so there are 301 digits

 Jul 6, 2023

2 Online Users

avatar