pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/40ebe948e97b47fc84c8f527910063286a174b25

"stylesheet" href="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> Document differences between random.choices() and random.choice(). (G… · python/cpython@40ebe94 · GitHub
Skip to content

Commit 40ebe94

Browse files
authored
Document differences between random.choices() and random.choice(). (GH-11703)
1 parent cf991e6 commit 40ebe94

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Doc/library/random.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ Functions for sequences
162162
with the :class:`float` values returned by :func:`random` (that includes
163163
integers, floats, and fractions but excludes decimals).
164164

165+
For a given seed, the :func:`choices` function with equal weighting
166+
typically produces a different sequence than repeated calls to
167+
:func:`choice`. The algorithm used by :func:`choices` uses floating
168+
point arithmetic for internal consistency and speed. The algorithm used
169+
by :func:`choice` defaults to integer arithmetic with repeated selections
170+
to avoid small biases from round-off error.
171+
165172
.. versionadded:: 3.6
166173

167174

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy