FAQ: Introduction to Data Science - Probability


This community-built FAQ covers the “Probability” exercise from the lesson “Introduction to Data Science”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Code Foundations

FAQs on the exercise Probability

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


I have zero knowledge of scientific probability so it may be just me, but on a purely common-sense level the result of this script feels completely counter-intuitive:
If there are 365 possible unique birth dates and there are 90 people in the room (i.e. 1/4 of the number of unique birthdates), how can the probability of two of them having the same birthday be “nearly 100%”?

Moreover, why does the script return an error if I enter a number of people higher than 120?


This is a well known problem called the birthday paradox.

When there are 23 people in a room, the probability of two having the same birthday is roughly 0.5. That number goes up quickly as more and more people enter the room. With 90 people in the room the chance of no two having the same birthday is very small, about 0.00002. So the probability that at least two people have the same birthday is 1 - 0.00002 which is still very close to 1.

>>> 90 * 89 / 2
>>> (364/365) ** 4005
>>> 1 - (364/365) ** 4005