I need assistance with the following python exercise:
Posted: Mon Jun 06, 2022 2:18 pm
I need assistance with the following python exercise:
13 The Cron acce FOLLOWI 14 1. STRING outlook 15 f 2. STRING windy Your supervisor wants you to write a program that takes in weather conditions to determine whether or not they should go and play golf. They currently use this decision tree to decide if he should play or not play. 16 #3. STRING humidity 17 18 Outlook 19 def playGolf (outlook, windy, humidity): #Write your code here 20 21 sunny 22 rainy outlook. 23 vif_name__ == '__main__': 24 outlook input() Windy 25 25 overcast windy=input() 27 false 28 humidity=input() true Play รา Don't Play Play Don't Play Play 30 playGolf (outlook, windy, humidity)... 31 To read this tree, first we would check the outlook. • If the outlook is rainy, then we check if it is windy. If windy is true, we don't play. If windy is false, we don't play. • If the outlook is overcast, then we can play. • If the outlook is sunny, then we check the humidity. If the humidity is high we don't play. If the humidity is normal, we play. Write a function playGolf that takes in the outlook, windy, and humidity as input and prints out either don't play or play. Examples: Input: "rainy", "True", "high" Output: "play" Input: "overcast", "False", "high" Output: "play" Note: • outlook is a str type and can only have the following values: "rainy", "overcast", "sunny" • windy is a str type and can only have the following values: "True", "False" • humidity is a str type and can only have the following values: "high", "normal" ] Humidity high normal
13 The Cron acce FOLLOWI 14 1. STRING outlook 15 f 2. STRING windy Your supervisor wants you to write a program that takes in weather conditions to determine whether or not they should go and play golf. They currently use this decision tree to decide if he should play or not play. 16 #3. STRING humidity 17 18 Outlook 19 def playGolf (outlook, windy, humidity): #Write your code here 20 21 sunny 22 rainy outlook. 23 vif_name__ == '__main__': 24 outlook input() Windy 25 25 overcast windy=input() 27 false 28 humidity=input() true Play รา Don't Play Play Don't Play Play 30 playGolf (outlook, windy, humidity)... 31 To read this tree, first we would check the outlook. • If the outlook is rainy, then we check if it is windy. If windy is true, we don't play. If windy is false, we don't play. • If the outlook is overcast, then we can play. • If the outlook is sunny, then we check the humidity. If the humidity is high we don't play. If the humidity is normal, we play. Write a function playGolf that takes in the outlook, windy, and humidity as input and prints out either don't play or play. Examples: Input: "rainy", "True", "high" Output: "play" Input: "overcast", "False", "high" Output: "play" Note: • outlook is a str type and can only have the following values: "rainy", "overcast", "sunny" • windy is a str type and can only have the following values: "True", "False" • humidity is a str type and can only have the following values: "high", "normal" ] Humidity high normal