Israel.Segundo
BAN USERdef get_hotels(score_list, min_avg_score):
hotel_list = {}
# Create a dictionary where we classify scores by hotel id
for hotel_score in score_list:
hotel_id = hotel_score['hotel_id']
if not hotel_id in hotel_list.keys():
hotel_list[hotel_id] = []
hotel_list[hotel_id].append(int(hotel_score['score']))
# Create a list of hotels that have at least the min_avg_score
hotel_result_list = []
for hotel_id in hotel_list.keys():
score_average = (sum(hotel_list[hotel_id]) / len(hotel_list[hotel_id]))
if score_average >= min_avg_score:
hotel_result_list.append(hotel_id)
return hotel_result_list
scores = [
{'hotel_id': 1001, 'user_id': 501, 'score': 7},
{'hotel_id': 1001, 'user_id': 502, 'score': 7},
{'hotel_id': 1001, 'user_id': 503, 'score': 7},
{'hotel_id': 2001, 'user_id': 504, 'score': 10},
{'hotel_id': 3001, 'user_id': 505, 'score': 5},
{'hotel_id': 2001, 'user_id': 506, 'score': 5}
]
print "get_hotels(scores,5) -> " + str(get_hotels(scores,5))
print "get_hotels(scores,7) -> " + str(get_hotels(scores,7))
RepCallaRita, techsupport at Knowledge Systems
Hi, I am an Administrative person . It is to develop and sustain an early childhood organisation. I was a teacher ...
RepI am a management dietitian who plans food programs . I use personal counselling , cooking demonstrations, lectures and workshops as a ...
RepEdwin Adcox, Dev Lead at Advisory Board Company
Welcome to the best and certified exotic car rental company of USA. Here, at Prestige luxury Rentals, we offer the ...
Repnormadyen, Blockchain Developer at 247quickbookshelp
I am working as a Pharmacy technician in Sunny Sypus company. I can maintain employee records for a company or ...
RepHazelMiller, Site Reliability Engineer at Delve Networks
Hazel Miller has been a stalwart advocate for sound public policy that advances the jobs creating potential of America’s ...
RepNY Vape Shop is the most popular Vaporizer Store for new trend vaporizer pen and all related accessories. We are ...
RepBlack magic mantra is simple and easy mantra. Call our specialist today for advice on black magic mantra to kill ...
- Israel.Segundo July 13, 2016