generate_number(pct_per_digit): Takes one float as input. Returns a random number that is constructed as follows. First, use the function above to get a random number. This number will correspond to the length (number of digits) that the number generated by this function should have. For example, if that function returns 3, then this function should generate and return a random number with three digits. Note that the first digit of the number should never be 0 (but further digits, if any, can be 0). Note: As there are different ways to write this function, we will not be checking the specific examples below but only that the numbers returned from the function (given a length of n as returned from the function above) are equally distributed in the range 10 n – 1) to (10") - 1. E.g., for n=5, from 10,000 to 99,999. That is, if we were to run your function many times, then any number in that range should be equally likely to be generated.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please use python

• generate_number(pct_per_digit): Takes one float as input. Returns a random number that is
constructed as follows. First, use the function above to get a random number. This number will
correspond to the length (number of digits) that the number generated by this function should have.
For example, if that function returns 3, then this function should generate and return a random
number with three digits. Note that the first digit of the number should never be 0 (but further
digits, if any, can be 0).
Note: As there are different ways to write this function, we will not be checking the specific examples
below but only that the numbers returned from the function (given a length of n as returned from
the function above) are equally distributed in the range 10'n – 1) to (10") – 1. E.g., for n=5, from
10,000 to 99,999. That is, if we were to run your function many times, then any number in that
range should be equally likely to be generated.
-
>>> random. seed(1337)
>>> generate_number(0)
>>> random. seed(9002)
>>> generate_number(0.5)
41700
Transcribed Image Text:• generate_number(pct_per_digit): Takes one float as input. Returns a random number that is constructed as follows. First, use the function above to get a random number. This number will correspond to the length (number of digits) that the number generated by this function should have. For example, if that function returns 3, then this function should generate and return a random number with three digits. Note that the first digit of the number should never be 0 (but further digits, if any, can be 0). Note: As there are different ways to write this function, we will not be checking the specific examples below but only that the numbers returned from the function (given a length of n as returned from the function above) are equally distributed in the range 10'n – 1) to (10") – 1. E.g., for n=5, from 10,000 to 99,999. That is, if we were to run your function many times, then any number in that range should be equally likely to be generated. - >>> random. seed(1337) >>> generate_number(0) >>> random. seed(9002) >>> generate_number(0.5) 41700
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education