Galton board · Python

Flashcards for Python lesson 3: Randomness and counting

Read the front, say the back to yourself, then open the card.

  • np.random.default_rng(seed)

    A random number generator; the same seed gives the same numbers.

  • array < 0.5

    An array of True and False; True counts as 1 when you add.

  • np.bincount(xs)

    How many times each whole number 0, 1, 2, … appears in xs.

  • [f(i) for i in k]

    A list comprehension: a new list with f applied to every item of k.

  • comb(n, k)

    The number of ways to choose k things out of n: math.comb(12, 6) is 924.

Back to the lesson