-
-
Save firstval/fee8fea3bd8fe3eaf72d to your computer and use it in GitHub Desktop.
This file contains 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
import random | |
random.seed(0) | |
def MakeData(): | |
Data = ["Spam"] * 5 | |
Data.extend(["Eggs"] * 2) | |
Data.extend(["Ham"] * 2) | |
return Data | |
def NonDeterministic(Data): | |
justSpam = set(Data) & set(["Spam"]) | |
IloveHam = set(Data) & set(["Ham"]) | |
TastyEgg = set(Data) & set(["Eggs"]) | |
Breakfast = justSpam | IloveHam | TastyEgg | |
DeliciousFactor = random.random() | |
return Breakfast, DeliciousFactor | |
def Deterministic(Data): | |
justSpam = [food for food in Data if food == "Spam"] | |
IloveHam = [food for food in Data if food == "Ham"] | |
TastyEgg = [food for food in Data if food == "Eggs"] | |
Breakfast = [] | |
Breakfast.extend([justSpam[0], IloveHam[0], TastyEgg[0]]) | |
DeliciousFactor = random.random() | |
return Breakfast, DeliciousFactor | |
menu = MakeData() | |
print (NonDeterministic(menu)) | |
print (Deterministic(menu)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment