At 04:35 AM 12/5/2007, bhaaluu wrote:
>It seems to be case-sensitive Mr. Moores!
>When I entered 'power' (like you did), I also got:
>help> 'power'
>no Python documentation found for 'power'
>
>Try entering: 'POWER' (all caps, just like in the output).
Thanks! I should have tried that.
Dick Moor
$ python
>>> help()
help> 'topics'
[snip]
CODEOBJECTS FRAMES POWER TUPLES
[snip]
help> 'POWER'
5.4 The power operator
The power operator binds more tightly than unary operators on its l
At 02:41 PM 12/4/2007, bhaaluu wrote:
I'm running the Python 2.4.3
interactive interpreter
in a Konsole at a bash prompt:
$ python
>>> help
Type help() for interactive help, or help(object) for help about
object.
But look what I get with Python 2.5.1 and Win XP:
==
On Dec 4, 2007 2:29 PM, Alan Gauld <[EMAIL PROTECTED]> wrote:
> "bhaaluu" <[EMAIL PROTECTED]> wrote
>
> > You can use Python itself for getting help:
> >
> help('random')
>
> Well, well. I've been busily importing everything I wanted help on,
> not realising I could just quote it!
>
> Now that
"bhaaluu" <[EMAIL PROTECTED]> wrote
> You can use Python itself for getting help:
>
help('random')
Well, well. I've been busily importing everything I wanted help on,
not realising I could just quote it!
Now that little insight has probably saved me an hour a year or more!
Thanks for t
Greetings,
Take a look at my first Python program for an example:
http://www.geocities.com/ek.bhaaluu/python/paperock.py.txt
That should give you an idea.
Also:
You can use Python itself for getting help:
>>> help('random')
Happy Programming!
--
b h a a l u u at g m a i l dot c o m
http://www.
Easy enough. You'll want to import the random module and use the functions
in it. Also, http://docs.python.org/lib/lib.html is going to be your best
friend. You'll notice on that page among many other things is a section on
random number generation.
As to your code:
>>>import random
>>>a = ran
Hello All,
I'm a bare beginner to python (or indeed) any programming. I'm helping
myself become more proficient by making a text adventure game. The problem is
I need a function (or module) that will generate a random number within a
range, say 1-20 for example. The ability to program t
I'm tempted to suggest using a hack to avoid floating point errors.
Anyway, it isn't choosing a number to ten decimal places. It's actually
out to 11 in both examples you gave. And it evaluates to correct because
your guesses were to at least 10 places, which is as far as you account
for in the
Greetings all,
It seems I forgot to subscribe to the list so I didn't receive any of
the replies. However, I did check the archive and found all of the
very helpful suggestions. Thanks for your time.
Based on the replies I was able to get this to more or less work.
However, one problem still exis
"Jim Hutchinson" <[EMAIL PROTECTED]> wrote
> program that "should" work but doesn't. It generates a random number
> between 1 and 2 out to 10 decimal places.
Ok, Here's the problem. You are trying to compare two floating
point numbers. But python stores data in binary and displays
it in decimal.
I need to start using the reply all button...
Andrew James wrote:
> while guess != number:
>guess = float(raw_input("Make another guess: "))
>if guess > number:
>print "Lower..."
>elif guess < number:
>print "Higher..."
>tries += 1
>
> You're asking people to change
On Thu, 4 Oct 2007, Jerry VanBrimmer wrote:
> I'm no Python wizard, I'm still learning myself. But I think you need
> another "if" statement to check if "guess" is equal to "number".
>
> if guess == number:
> print "Congratulations!"
No, he's got the equivalent function in his while statemen
On Thu, 4 Oct 2007, Jim Hutchinson wrote:
> Any idea what I'm doing wrong?
> while (guess != number):
This is your problem. Like all^h^h^h most numbers in computing, floating
point numbers are stored in binary. They only approximate the decimal
values they print out as.
Two numbers can prin
I'm no Python wizard, I'm still learning myself. But I think you need
another "if" statement to check if "guess" is equal to "number".
if guess == number:
print "Congratulations!"
Something like that.
On 10/4/07, Jim Hutchinson <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am writing a little
Hello,
I am writing a little program to test a theory and as part of teaching
myself Python. I've only been at this about a week now. I have a
program that "should" work but doesn't. It generates a random number
between 1 and 2 out to 10 decimal places. I think there is something
wrong with how my
Johan Geldenhuys wrote:
> After I tested the previous code, I noticed that the odds is 1:49 that a
> duplicate number can be found in the 6 digit range (and it happended)
> and that 0 can also be found.
Look at random.sample() for a simpler way to do this.
Kent
>
> Here is the fix:
>
> import
After I tested the previous code, I noticed that the odds is 1:49 that
a duplicate number can be found in the 6 digit range (and it happended)
and that 0 can also be found.
Here is the fix:
import random
def randnum():
c = []
for x in range(6):
s = random.randrange(0, 50)
18 matches
Mail list logo