Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Classical Probability and Counting | Section
Exploring Probability Theory
Секція 1. Розділ 2
single

single

bookClassical Probability and Counting

Свайпніть щоб показати меню

The classical definition of probability is based on the idea that if all outcomes of an experiment are equally likely, the probability of an event is the ratio of the number of favorable outcomes to the total number of possible outcomes. The formula is:

Classical Probability Formula:

P(A)=Number of favorable outcomesTotal number of possible outcomesP(A) = \frac{\text{Number of favorable outcomes}}{\text{Total number of possible outcomes}}

For example, if you toss a fair coin, there are two equally likely outcomes: heads or tails. The probability of getting heads is 1/21/2. If you roll a standard six-sided die, each face (1 through 6) is equally likely, so the probability of rolling a 4 is 1/61/6.

Let's consider another example:
Suppose you roll a pair of dice. The total number of possible outcomes is 6×6=366 × 6 = 36, since each die has 6 faces. The probability of rolling a sum of 7 is the number of outcomes where the dice add up to 7 divided by 36.

123456789101112131415
import random # Simulate rolling a six-sided die 6000 times and calculate the frequency of each outcome trials = 6000 outcomes = [0] * 6 # List to store counts for faces 1 through 6 for _ in range(trials): roll = random.randint(1, 6) outcomes[roll - 1] += 1 # Calculate the probability for each face probabilities = [count / trials for count in outcomes] for i, prob in enumerate(probabilities, start=1): print(f"Probability of rolling {i}: {prob:.3f}")
copy
Завдання

Проведіть, щоб почати кодувати

Calculate the probability of drawing a red card from a standard deck of 52 playing cards in the global scope.

  • Assign the number of red cards (26) to the variable total_red.
  • Assign the total number of cards (52) to the variable total_cards.
  • Compute the probability as the ratio of red cards to the total number of cards and assign it to the variable probability as a floating-point number.
  • Print the resulting probability.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 2
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

some-alt