Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random numbers

Status
Not open for further replies.

Ordos

Programmer
May 15, 2005
1
0
0
US
Hey Iam a very new Python programmer seeking to learn more languages. I was wondering what Pythons command to get a random number is? With php its like rand(1,10) but what is it for Python? I couldnt figure it out so any help would be nice :D
 
You must import random module
an example could be:

import random
random.randrange(0,10)

# where 0 is start and 10 is stop.
if you add another number like (0,10,2) means that in this case 2 is the step.

I hope it helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top