Created
February 9, 2016 04:43
-
-
Save somombo/ddc3a9d434b65f42d5d2 to your computer and use it in GitHub Desktop.
This file contains 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
class TrueRandom: | |
def __init__(self): | |
from decimal import Decimal | |
import urllib.request | |
myURL = "http://www.random.org/decimal-fractions/?num=1&dec=20&col=1&format=plain&rnd=new" | |
response = urllib.request.urlopen(myURL) | |
strHTM = bytes.decode(response.read()) | |
self.__decRan = Decimal(strHTM) | |
self.__fltRan = float(strHTM) | |
def getDecimal(self): | |
return self.__decRan | |
def getFloat(self): | |
return self.__fltRan | |
def rand(): | |
x = TrueRandom() | |
print(x.getDecimal()) | |
print(x.getFloat()) | |
rand() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generate True Random Numbers using Random.org