forked from jennielees/oh-no-broken-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvacation.py
More file actions
79 lines (59 loc) · 1.96 KB
/
vacation.py
File metadata and controls
79 lines (59 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# This file has a few mistakes and some things I forgot to put in.
# When I run it I don't get anything... can you fix it so I
# get asked for my vacation spot, and get a recommendation?
# Hint:
# Start at the bottom and work upwards.
vacation_spots = ['Tahoe', 'Hawaii', 'New York', 'Mexico']
seasons = ['spring', 'summer', 'fall', 'winter']
weather_patterns = {
'spring': 'rain',
'summer': 'sun',
'fall': 'wind',
'winter': 'snow'
}
activities = {
'rain': 'visiting museums',
'wind': 'kiteboarding',
'sun': 'sunbathing',
'snow': 'skiing'
}
weather_location_map = {
'snow': 'Tahoe',
'wind': 'Hawaii',
'rain': 'New York',
'sun': 'Mexico'
}
def best_vacation_spot(weather_type):
# Look at the weather type and return the vacation spot that
# is the best for that weather.
# You can use this mapping:
# snow = Tahoe
# wind = Hawaii
# rain = New York
# sun = Mexico
vacation_spot = weather_location_map[weather_type]
return vacation_spot
# return "Stay at home"
def vacation_activity(weather_type):
# Look up the vacation activity from activities
# and return just the activity itself
activity = activities[weather_type]
return activity
def get_my_vacation():
season = raw_input("What season do you want to travel? ")
# check if season is in the seasons list
if season not in seasons:
print "Sorry, that isn't a season. I can't help you."
else:
# look up the weather type for that season
weather_type = weather_patterns[season]
# get the best vacation spot for that type
spot = best_vacation_spot(weather_type)
# get the best vacation activity for that type
activity = vacation_activity(weather_type)
print "You should travel to {}, where you can spend your time {}!".format(spot, activity)
def main():
print "Welcome to the Vacation-o-Matic!"
get_my_vacation()
if __name__=="__main__":
main()