[Python] Difference between randrange () and randint ()

environment

-Python 3.8.5 ・ Osx10.15.6

Introduction

When I used a random number for the first time in Python, there was a similar notation, so I wrote the difference.

What is randrange ()

random.randrange (a, b) returns an integer from "a" to "b-1". If there is one argument, an integer with an argument minus 1 is returned from "0".

What is random.randint ()?

random.randint (a, b) returns an integer from "a" to "b".

The difference is

The difference between including or not including the last number! random.randrange (a, b) does not include the last value, so combine it with len (array) Convenient for iterating arrays!

reference

About the random function ・ Https://www.lifewithpython.com/2013/04/random.html

Recommended Posts

[Python] Difference between randrange () and randint ()
Difference between Ruby and Python split
Difference between java and python (memo)
Difference between list () and [] in Python
Difference between == and is in python
[Python] Difference between function and method
Python --Difference between exec and eval
[Python] Difference between sorted and sorted (Colaboratory)
Difference between PHP and Python finally and exit
Difference between @classmethod and @staticmethod in Python
Difference between append and + = in Python list
Difference between nonlocal and global in Python
[Python] Difference between class method and static method
[Python Iroha] Difference between List and Tuple
[python] Difference between rand and randn output
[python] Difference between variables and self. Variables in class
About the difference between "==" and "is" in python
Difference between process and job
Difference between "categorical_crossentropy" and "sparse_categorical_crossentropy"
Difference between regression and classification
About Python, len () and randint ()
Difference between np.array and np.arange
Difference between MicroPython and CPython
Difference between ps a and ps -a
Difference between return and print-Python
Difference between Ruby and Python in terms of variables
Difference between return, return None, and no return description in Python
Difference between SQLAlchemy filter () and filter_by ()
Python> Difference between inpbt and print (inpbt) output> [1. 2. 3.] / array ([1., 2., 3.], dtype = float32)
Memorandum (difference between csv.reader and csv.dictreader)
List concatenation method in python, difference between list.extend () and “+” operator
(Note) Difference between gateway and default gateway
Cooperation between python module and API
Differences between Python, stftime and strptime
Difference between sort and sorted (memorial)
Difference between SQLAlchemy flush () and commit ()
Difference in how to write if statement between ruby ​​and python
Python / Numpy> Link> Difference between numpy.random and random.random> thread-safe or not
File open function in Python3 (difference between open and codecs.open and speed comparison)
Communicate between Elixir and Python with gRPC
Differences in authenticity between Python and JavaScript
Differences between Ruby and Python in scope
[Xg boost] Difference between softmax and softprob
[Django ORM] Difference between values () and only ()
Differences in syntax between Python and Java
Difference between linear regression, Ridge regression and Lasso regression
Difference between docker-compose env_file and .env file
[Python3] Switch between Shift_JIS, UTF-8 and ASCII
speed difference between wsgi, Bottle and Flask
Differences in multithreading between Python and Jython
Differences between Ruby and Python (basic syntax)
Difference between numpy.ndarray and list (dimension, size)
Correspondence between Python built-in functions and Rust
Difference between ls -l and cat command
Exchange encrypted data between Python and C #
Difference and compatibility verification between keras and tf.keras # 1
[Introduction to Python] What is the difference between a list and a tuple?
What is the difference between `pip` and` conda`?
Summary of the differences between PHP and Python
The answer of "1/2" is different between python2 and 3
Difference between using and import on shield language