Created
March 8, 2019 08:14
-
-
Save halexus/c550dcaf2ca061825f8084918ba502a6 to your computer and use it in GitHub Desktop.
Python Lösung Beispiel 4 Wahrscheinlichkeitstheorie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product # Kartesisches Produkt | |
from fractions import Fraction # Brüche | |
def X1(w): # Augenzahl erster Würfel | |
return w[0] | |
def X2(w): # Augenzahl zweiter Würfel | |
return w[1] | |
omega = list(product(range(1,7), range(1,7))) # Ergebnismenge | |
print(sorted({X1(w)*X2(w) for w in omega})) # Wertemenge X1*X2 | |
print([str(x) for x in sorted({Fraction(X1(w), X2(w)) for w in omega})]) # Wertemenge X1/X2 | |
print(sorted({2*X1(w) - 3*X2(w) for w in omega})) # Wertemenge 2*X1 - 3*X2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment