Question: Submit a python program that counts the number of 0's involved in writing out all the numbers from 1 to a user provided target value,
Submit a python program that counts the number of 0's involved in writing out all the numbers from 1 to a user provided target value, and measures the time required for that counting process.Use the pseudocode shown below to guide you:

count 0 repeat count count + the number of zeros in n until nis 1 million display count Of course, how can the number of zeros in n be counted? An algorithm for this could be: zeros 0 repeat if n % 10 is 0 then zeros zeros + 1 end nn/10 until nis (0 In addition, your program should calculate how long it took to provide a result. To do this, you will make use of a Python library called time. Details are located below. Structure your output so that it is like mine. Here's output of a sample run (user input is shown in bold red) What number do you want to count zeros to? 1000000 The number of zeros written from 1 to 1000000 is 488895 This took 1.46663212776 seconds Python provides a time library that includes a function that returns the current time. Import this functionality as follows: You can get the current time as follows Here's sample output of a call to the function time0: from time import time time () 1510841671.210023 How is this a time at all? Actually, the value returned represents the number of seconds elapsed since an epoch defined in your operating system. For Unix and Unix-like operating systems (e g., the "flavor" of Linux used on the Raspberry Pi), the epoch is 1970-01-01 00:00:00. Regardless of what the epoch time actually is, by capturing a start time and an end time, we can calculate the difference to obtain the time elapsed of some portion of code. Here's an example starttime time() # do algorithm stuff here stop-time time ( )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
