#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# A little help using randint(), please...

Posts: 20Member
Hi! Could anyone please explain exactly how to use randint()? I have read in the help and in the example that comes with python but i still cannot get it... please help!
· ·

• Posts: 2,900Member
: Hi! Could anyone please explain exactly how to use randint()? I have read in the help and in the example that comes with python but i still cannot get it... please help!

What is there to get?

[code]
>>> import random
>>> help(random.randint)
Help on method randint in module random:

randint(self, a, b) method of random.Random instance
Return random integer in range [a, b], including both end points.
[/code]

If you want to pick a random integer between 1 and 6 (to simulate a die roll, perhaps), you call random.randint(1, 6).

[size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

[code]
\$ select * from users where clue > 0
no rows returned
[/code]

· ·
• Posts: 20Member
: : Hi! Could anyone please explain exactly how to use randint()? I have read in the help and in the example that comes with python but i still cannot get it... please help!
:
: What is there to get?
:
: [code]
: >>> import random
: >>> help(random.randint)
: Help on method randint in module random:
:
: randint(self, a, b) method of random.Random instance
: Return random integer in range [a, b], including both end points.
: [/code]
:
: If you want to pick a random integer between 1 and 6 (to simulate a die roll, perhaps), you call random.randint(1, 6).
:
:
: [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
:
: [code]
: \$ select * from users where clue > 0
: no rows returned
: [/code]
:
:
That helped a lot, Thanks!
· ·