import math
from statistics import mean
# here we will find the answer to playing assuming the outlook is sunny, the temperature is cool, the humidity is high, and the wind is strong
outlook = ["sunny", "sunny", "overcast", "rainy", "rainy", "rainy", "overcast", "sunny", "sunny", "rainy", "sunny", "overcast", "overcast", "rainy"]
temperature = ["hot", "hot", "hot", "mild", "cool", "cool", "cool", "mild", "cool", "mild", "mild", "mild", "hot", "mild"]
humidity = ["high", "high", "high", "high", "normal", "normal","normal", "high", "normal", "normal", "normal", "high", "normal", "high"]
windy = ["false", "true", "false", "false", "false", "true", "true", "false", "false", "false", "true", "true", "false", "true"]
play = ["no", "no", "yes", "yes", "yes", "no", "yes", "no", "yes", "yes", "yes", "yes", "yes", "no"]
#print (len(temperature))
#print (len(outlook))
#print (len(humidity))
#print (len(windy))
#print (len(play))
sunny = 0
cool = 0
high = 0
strong = 0
for i in range(14):
if outlook[i] == "sunny":
sunny+= 1
if temperature[i] == "cool":
cool += 1
if humidity[i] == "high":
high+= 1
if windy[i] == "true":
strong+= 1
print (sunny)
print (cool)
print (high)
print (strong)
countYes = 0
countNo = 0
length = len(play)
for i in range(length):
if play[i] == "no":
countNo += 1
else:
countYes += 1
print (countNo)
print (countYes)
probYesWindy = 0
probNoWindy = 0
probYesNoWindy = 0
probNoNoWindy = 0
probYes = countYes / 14
probNo = countNo / 14
for i in range(length):
if play[i] == "yes":
if windy[i] == "false":
probYesNoWindy += 1
if windy[i] == "true":
probYesWindy += 1
if play[i] == "no":
if windy[i] == "false":
probNoNoWindy += 1
if windy[i] == "true":
probNoWindy += 1
YesWindy = probYesWindy/countYes
NoWindy = probNoWindy / countNo
YesNoWindy = probYesNoWindy/countYes
NoNoWindy = probNoNoWindy / countNo
print (YesWindy)
print (NoWindy)
probYesHigh = 0
probNoHigh = 0
probYesNormal = 0
probNoNormal = 0
for i in range(length):
if play[i] == "yes":
if humidity[i] == "high":
probYesHigh += 1
if humidity[i] == "normal":
probYesNormal += 1
if play[i] == "no":
if humidity[i] == "high":
probNoHigh += 1
if humidity[i] == "normal":
probNoNormal += 1
yesHigh = probYesHigh/countYes
noHigh = probNoHigh / countNo
yesNormal = probYesNormal/countYes
noNormal = probNoNormal / countNo
print (yesHigh)
print (noHigh)
probYesSunny = 0
probNoSunny = 0
probYesOvercast = 0
probNoOvercast = 0
probYesRainy = 0
probNoRainy = 0
for i in range(length):
if play[i] == "yes":
if outlook[i] == "sunny":
probYesSunny += 1
if outlook[i] == "overcast":
probYesOvercast += 1
if outlook[i] == "rainy":
probYesRainy += 1
if play[i] == "no":
if outlook[i] == "sunny":
probNoSunny += 1
if outlook[i] == "overcast":
probNoOvercast += 1
if outlook[i] == "rainy":
probNoRainy += 1
YesSunny = probYesSunny/countYes
NoSunny = probNoSunny / countNo
YesOvercast = probYesOvercast/countYes
NoOvercast = probNoOvercast / countNo
YesRainy = probYesRainy / countYes
NoRainy = probNoRainy / countNo
print (YesSunny)
print (NoSunny)
probYesHot = 0
probNoHot = 0
probYesMild = 0
probNoMild = 0
probYesCool = 0
probNoCool = 0
for i in range(length):
if play[i] == "yes":
if temperature[i] == "hot":
probYesHot += 1
if temperature[i] == "mild":
probYesMild += 1
if temperature[i] == "cool":
probYesCool += 1
if play[i] == "no":
if temperature[i] == "hot":
probNoHot += 1
if temperature[i] == "mild":
probNoMild += 1
if temperature[i] == "cool":
probNoCool += 1
YesHot = probYesHot/countYes
NoHot = probNoHot / countNo
YesMild = probYesMild /countYes
NoMild = probNoMild / countNo
YesCool = probYesCool / countYes
NoCool = probNoCool / countNo
print (YesCool)
print (NoCool)
pYes = (YesSunny) * (YesCool) * (yesHigh) * (YesWindy) * (probYes)
pNo = (NoSunny) * (NoCool) * (noHigh) * (NoWindy) * (probNo)
print (pYes)
print (pNo)
commonP = (sunny/14) * (high / 14) * (cool /14) * (strong/ 14)
finalYes= pYes / commonP
finalNo = pNo / commonP
if finalYes > finalNo:
print ("Go out and play. The chances of you playing are " + str(finalYes) + " and the chances you don't are " + str(finalNo))
else:
print ("Do not go out and play. The chances of you playing are " + str(finalYes) + " and the chances you don't are " + str(finalNo))