Skip to content

Instantly share code, notes, and snippets.

@somombo
Created February 9, 2016 04:43
Show Gist options
  • Save somombo/ddc3a9d434b65f42d5d2 to your computer and use it in GitHub Desktop.
Save somombo/ddc3a9d434b65f42d5d2 to your computer and use it in GitHub Desktop.
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()
@somombo
Copy link
Author

somombo commented Feb 9, 2016

Generate True Random Numbers using Random.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment