Skip to content

Instantly share code, notes, and snippets.

@paulohrpinheiro
Created April 4, 2017 14:27
Show Gist options
  • Save paulohrpinheiro/efd1e099e5162eafd482109c928c72ec to your computer and use it in GitHub Desktop.
Save paulohrpinheiro/efd1e099e5162eafd482109c928c72ec to your computer and use it in GitHub Desktop.
Quantos números aleatórios gero em 1 segundo? - Python
import sys
import random
import signal
def handler(signum, frame):
print(how_many)
sys.exit()
signal.signal(signal.SIGALRM, handler)
signal.alarm(1)
how_many = 0
try:
while(True):
random.randrange(100)
how_many += 1
except:
signal.alarm(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment