DEV Community

Aditi Sharma
Aditi Sharma

Posted on

πŸš€ Day 22 of My Python Learning Journey

Probability & Events in Python 🎲

Today I explored the basics of probability β€” the math of uncertainty!

πŸ”Ή Key Concepts:
β€’ Probability Formula β†’ P(E) = Favorable outcomes / Total outcomes
β€’ Events:
Independent β†’ coin tosses 🎯
Dependent β†’ drawing cards without replacement πŸƒ
Mutually Exclusive β†’ can’t happen together (odd vs even on a die).

πŸ”Ή Python Practice:

import random

Simulate coin toss

outcomes = ["H", "T"]
print(random.choice(outcomes))

⚑ Fun Facts:
β€’ Rolling a 6 on a fair die has a probability of 1/6 β‰ˆ 16.67%.
β€’ Probability powers AI, insurance, weather forecasting & even Netflix recommendations! πŸ“ˆ

Python #Probability #100DaysOfCode #DataScience #CodingJourney

Top comments (0)