Site menu

CodeCook.io

  • Languages
    • C
    • C++
    • CSS
    • Git
    • HTML
    • Java
    • JavaScript
    • jQuery
    • PHP
    • Python
    • Ruby
    • Scala
  • integer
  • random
  • range

Python - Random integer in range

Get random integer in range between a lower and upper bound. Random whole number is between lower and upper where it can be equal to lower (inclusive) but never equal to upper (exclusive).

Lower bound
Upper bound
0
506
  • Share on Facebook
  • Share on Google+
  • Share on Twitter

Using buildin random.randint

Request

from random import randint
randint({{lower}}, {{upper}})
python
  • documentation

Notes

Value between lower (including) and upper (excluding) [integer]

last update: Feb. 8, 2015

Advertisement

This project is hosted on DigitalOcean, try it and support us

Related concept

  • Create a list of integers
  • Range of alphabet chacters

Other language

  • JavaScript

Random task

  • Prepend item to array
  • Get absolute url of current page
  • Check console available
  • Stop docker container
  • Get multiple values from an object.
  • Blog
  • About
  • License