Challenge
Tarefa
Swipe to start coding
Let's imagine one situation that may be real for you. You have a tasty basket with:
5
cookies with a cherry jam,5
chocolate cookies,10
chocolate candies,5
chocolate bars,15
biscuits,10
bottles of lemonade.
Calculate the probability that you will randomly pull out an item that includes chocolate, or a cookie.
We can divide our food into influential groups:
- The first one: cookies (ones with cherry jam and chocolate ones).
- The second one: is chocolate items (chocolate bars, candies, and chocolate cookies).
Follow the algorithm:
- Calculate the probability of pulling out a cookie.
- Calculate the probability of pulling out item that includes chocolate (chocolate sweet).
- Calculate the probability of pulling out a chocolate cookie.
- Calculate the resulting probability.
Solução
99
1
2
3
4
5
6
7
8
9
10
11
# Calculate the probability of getting cookie
P_cookie = 10 / 50
# Calculate the probability of getting chocolate sweets
P_chocolate = 20 / 50
# Calculate the probability of getting chocolate cookie
P_chocolate_cookie = 5 / 50
# Calculate the resulting probability
P = P_cookie + P_chocolate - P_chocolate_cookie
print("The probability is:", P)
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 3
99
1
2
3
4
5
6
7
8
9
10
11
# Calculate the probability of getting cookie
P_cookie = ___ / 50
# Calculate the probability of getting chocolate sweets
P_chocolate = ___ / ___
# Calculate the probability of getting chocolate cookie
P_chocolate_cookie = ___
# Calculate the resulting probability
P = P_cookie + ___ - ___
print("The probability is:", P)
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo