Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Introduction to Python Camp Sunny Daze has hired you as their new Activity Direc

ID: 3793942 • Letter: I

Question

Introduction to Python

Camp Sunny Daze has hired you as their new Activity Director. You are required to choose activities for the campers based on the weather predictions for that week. Given a list containing some number of integer values (each representing the average temperature for one day), your schedule() function should return a corresponding list of strings representing daily activities.

Your menu of possible activities, based on temperature, is as follows:

• 90 degrees or higher: swimming

• 80–89 degrees: hiking

• 70–79 degrees: tennis

• 60–69 degrees: softball

• 50–59 degrees: football

• 49 degrees or below: movie

For example, if the day’s predicted temperature is 72 (degrees), that day’s activity will be tennis. Complete the schedule() function, which takes a list of positive integer values as its sole argument, and returns an equivalently-sized list of strings. Each string will match one of the activities listed above (in all lowercase), according to the value of the integer in that position in the parameter list (for example, if the first value in the input list is 61, the first value in the output list will be “softball”).

Example:

--------------

Function Call Return Value schedule([72, 84, 55]) ["tennis", "hiking", "football"] schedule([95, 63, 70]) ["swimming", "softball", "tennis"] schedule([44, 56, 68, 92]) ["movie", "football", "softball", "swimming"]

Explanation / Answer

def schedule(temperatures):
'''
input: list of temperatues
output: list of matching games
'''
game = []
for i in range(0,len(temperatures)):
if (temperatures[i] >= 90):
game.append('swimming')
elif (temperatures[i] <= 89 and temperatures[i] > 79):
game.append('hiking')
elif (temperatures[i] <= 79 and temperatures[i] > 69):
game.append('tennis')
elif (temperatures[i] <= 69 and temperatures[i] > 59):
game.append('softball')
elif (temperatures[i] <= 59 and temperatures[i] > 49):
game.append('football')
elif (temperatures[i] <= 49):
game.append('movie')
return game
  
temperatures = []

print("please input temperatures.")
i = 0
while i == 0:
inp = input()
if inp != '':
temperatures.append(int(inp))
else:
i = 1

print(schedule(temperatures))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote