Python Forum
random numbers and stats - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: random numbers and stats (/thread-8471.html)



random numbers and stats - cliffhop23 - Feb-21-2018

2. Part 2 - Statistics on Random Numbers - 5pts
Generate 500 random numbers on the interval 1 to 65536. Determine the fraction of these numbers which are greater than or equal to 512 and less than or equal to 2048. Display the result. Stop execution by means of an input statement which asks the user if they want to execute the next part of the assignment, prompt for a ’Y’ to continue or ’N’ to terminate execution.

import random
for x in range(500):
print random.randint(1,65536)
I need help with the second part


random number lists and statistics - cliffhop23 - Feb-21-2018

Generate 500 random numbers on the interval 1 to 65536. Determine the fraction of these numbers which are greater than or equal to 512 and less than or equal to 2048. Display the result. Stop execution by means of an input statement which asks the user if they want to execute the next part of the assignment, prompt for a ’Y’ to continue or ’N’ to terminate execution.

import random
for x in range(500):
	print random.randint(1,65536)
[hr]
[python]
import random
for x in range(500):
	print random.randint(1,65536)



RE: random numbers and stats - glidecode - Feb-22-2018

Your code repeats itself and you haven't asked any questions?
Seems like the next step is a test condition like:
if  512 < x and < 2048