There are two problems here:
You forgot to actually invoke
GetRandom.ranNumber. Add()after it to do this:bnum = b.ranNumber()You need to make
GetRandom.ranNumberaccept theselfselfargument that is passed implicitly when you invoke the method:def ranNumber(self): return random.random()
Once you address these issues, the code works as expected:
>>> import random
>>> class GetRandom:
... def __init__(self):
... self.data = ""
... def ranNumber(self):
... return random.random()
...
>>> b = GetRandom()
>>> bnum = b.ranNumber()
>>> print bnum
0.819458844177
>>>
There are two problems here:
You forgot to actually invoke
GetRandom.ranNumber. Add()after it to do this:bnum = b.ranNumber()You need to make
GetRandom.ranNumberaccept theselfargument that is passed implicitly when you invoke the method:def ranNumber(self): return random.random()
Once you address these issues, the code works as expected:
>>> import random
>>> class GetRandom:
... def __init__(self):
... self.data = ""
... def ranNumber(self):
... return random.random()
...
>>> b = GetRandom()
>>> bnum = b.ranNumber()
>>> print bnum
0.819458844177
>>>
There are two problems here:
You forgot to actually invoke
GetRandom.ranNumber. Add()after it to do this:bnum = b.ranNumber()You need to make
GetRandom.ranNumberaccept theselfargument that is passed implicitly when you invoke the method:def ranNumber(self): return random.random()
Once you address these issues, the code works as expected:
>>> import random
>>> class GetRandom:
... def __init__(self):
... self.data = ""
... def ranNumber(self):
... return random.random()
...
>>> b = GetRandom()
>>> bnum = b.ranNumber()
>>> print bnum
0.819458844177
>>>
There are two problems here:
You forgot to actually invoke
GetRandom.ranNumber. Add()after it to do this:bnum = b.ranNumber()You forgotneed to make
GetRandom.ranNumberaccept theselfselfargument that is passed implicitly when you invoke the method. You need to define it like so:def ranNumber(self): return random.random()
Once you fixaddress these two problemsissues, the code works fineas expected:
>>> import random
>>> class GetRandom:
... def __init__(self):
... self.data = ""
... def ranNumber(self):
... return random.random()
...
>>> b = GetRandom()
>>> bnum = b.ranNumber()
>>> print bnum
0.819458844177
>>>
There are two problems here:
You forgot to invoke
GetRandom.ranNumber. Add()after it to do this:bnum = b.ranNumber()You forgot to make
GetRandom.ranNumberaccept theselfargument that is passed implicitly when you invoke the method. You need to define it like so:def ranNumber(self): return random.random()
Once you fix these two problems, the code works fine:
>>> import random
>>> class GetRandom:
... def __init__(self):
... self.data = ""
... def ranNumber(self):
... return random.random()
...
>>> b = GetRandom()
>>> bnum = b.ranNumber()
>>> print bnum
0.819458844177
>>>
There are two problems here:
You forgot to actually invoke
GetRandom.ranNumber. Add()after it to do this:bnum = b.ranNumber()You need to make
GetRandom.ranNumberaccept theselfargument that is passed implicitly when you invoke the method:def ranNumber(self): return random.random()
Once you address these issues, the code works as expected:
>>> import random
>>> class GetRandom:
... def __init__(self):
... self.data = ""
... def ranNumber(self):
... return random.random()
...
>>> b = GetRandom()
>>> bnum = b.ranNumber()
>>> print bnum
0.819458844177
>>>
There are two problems here:
You forgot to invoke
GetRandom.ranNumber. Add()after it to do this:bnum = b.ranNumber()You forgot to make
GetRandom.ranNumberaccept theselfargument that is passed implicitly when you invoke the method. You need to define it like so:def ranNumber(self): return random.random()
Once you fix these two problems, the code works fine:
>>> import random
>>> class GetRandom:
... def __init__(self):
... self.data = ""
... def ranNumber(self):
... return random.random()
...
>>> b = GetRandom()
>>> bnum = b.ranNumber()
>>> print bnum
0.819458844177
>>>