![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Hobbyist Programmer
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5
![]() |
Quote:
from __future__ import division
__________________
[ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ]; /* Don't make me use it! */ |
|
|
|
|
|
|
#12 |
|
Newbie
Join Date: Aug 2005
Posts: 5
Rep Power: 0
![]() |
Thanks, I got that working. Now how do I generate a random number?
You know what would be helpful? Are there any webpages with a list of python commands and what syntax to use with them? That would be really helpful. Thanks. |
|
|
|
|
|
#13 |
|
Hobbyist Programmer
Join Date: Aug 2005
Location: Hiding from... them...
Posts: 110
Rep Power: 4
![]() |
The random module has what you're looking for. See http://docs.python.org/lib/module-random.html.
BTW, docs.python.org is where to look for python documentation. |
|
|
|
|
|
#14 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
have you tried www.python.org. They have good documentations and some tutorial for starters.
EDIT: oops, posted at the same time with Silvanos. |
|
|
|
|
|
#15 |
|
Programmer
Join Date: Feb 2005
Posts: 54
Rep Power: 4
![]() |
BTW - you could use the float() function to change the integer into a real number for division:
>>> x = 12 >>> y = 5 >>> x/y 2 >>> x/float(y) 2.3999999999999999 |
|
|
|
|
|
#16 | ||
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Quote:
Just a small nag - it doesn't "change" the variable. That implies that the float function changes the data type in-place, so after something like x = 1 float(x) Quote:
|
||
|
|
|
|
|
#17 |
|
Newbie
Join Date: Aug 2005
Posts: 5
Rep Power: 0
![]() |
When I type 'random(1,14)' it tells me "NameError: name 'random' is not defined". What am I doing wrong?
|
|
|
|
|
|
#18 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Did you import the random module?
import random |
|
|
|
|
|
#19 |
|
Programming Guru
![]() |
I could have sworn it was " random.randrange(lower, upper) "
![]() |
|
|
|
|
|
#20 |
|
Newbie
Join Date: Aug 2005
Posts: 5
Rep Power: 0
![]() |
Thanks. I got it working now.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|