Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
a3950e42
Kaydet (Commit)
a3950e42
authored
Kas 17, 2016
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Small edits to the docs for sample() and shuffle().
üst
0a1a909f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
random.rst
Doc/library/random.rst
+14
-8
No files found.
Doc/library/random.rst
Dosyayı görüntüle @
a3950e42
...
...
@@ -152,13 +152,19 @@ Functions for sequences:
.. function:: shuffle(x[, random])
Shuffle the sequence *x* in place. The optional argument *random* is a
0-argument function returning a random float in [0.0, 1.0); by default, this is
the function :func:`.random`.
Shuffle the sequence *x* in place.
Note that for even rather small ``len(x)``, the total number of permutations of
*x* is larger than the period of most random number generators; this implies
that most permutations of a long sequence can never be generated.
The optional argument *random* is a 0-argument function returning a random
float in [0.0, 1.0); by default, this is the function :func:`.random`.
To shuffle an immutable sequence and return a new shuffled list, use
``sample(x, k=len(x))`` instead.
Note that even for small ``len(x)``, the total number of permutations of *x*
can quickly grow larger than the period of most random number generators.
This implies that most permutations of a long sequence can never be
generated. For example, a sequence of length 2080 is the largest that
can fit within the period of the Mersenne Twister random number generator.
.. function:: sample(population, k)
...
...
@@ -175,9 +181,9 @@ Functions for sequences:
Members of the population need not be :term:`hashable` or unique. If the population
contains repeats, then each occurrence is a possible selection in the sample.
To choose a sample from a range of integers, use a
n
:func:`range` object as an
To choose a sample from a range of integers, use a :func:`range` object as an
argument. This is especially fast and space efficient for sampling from a large
population: ``sample(range(10000000), 60)``.
population: ``sample(range(10000000),
k=
60)``.
If the sample size is larger than the population size, a :exc:`ValueError`
is raised.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment