I\'m new to Python. While reading, please mention any other suggestions regarding ways to improve my Python code.
Question: How do I generate a 8x
Just a comment on your runtime analysis of the problem - my intuition is that O(n) is the best possible runtime you can possibly obtain when generating O(n) truly random numbers.
Have you tried actually running your code with n = 10 million? Your assumption that the runtime will scale by 1000 when the input grows by a factor of 1000 may not be true in practice, as there is usually a constant term when executing any program (loading libraries, etc.), which may be significant depending on the problem.
That being said, it looks like the question linked by Eric Wright does a very thorough job and can easily be adapted to fit your question.