Created
April 4, 2017 14:27
-
-
Save paulohrpinheiro/efd1e099e5162eafd482109c928c72ec to your computer and use it in GitHub Desktop.
Quantos números aleatórios gero em 1 segundo? - Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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