今天算概率的时候想偷懒图片说明

于是:

from fractions import Fraction
a = Fraction(1, 2)
b = Fraction(1, 3)
c = Fraction(1, 5)
ab = Fraction(1, 10)
ac = Fraction(1, 15)
bc = Fraction(1, 20)
abc = Fraction(1, 30)
print(a + b + c - ab - ac - bc + abc)