def main(): print('Drug Use By Age') research.init() print() msg = "Highest Percentage of those in a age group who used alcohol in the past 12 months" print(msg) print() data = research.highest_alcohol_use() for idx, r in enumerate(data[:5],1): print(f'{idx}. {r.alcohol_use} % of age group: {r.age} years used alcohol {int(r.alcohol_frequency)} number of times (median)') app_log.trace(f'QUERY: {msg}') print() msg = "Highest Percentage of those in a age group who used marijuana in the past 12 months" print(msg) print() data = research.highest_marijuana_use() for idx, r in enumerate(data[:5],1): print(f'{idx}. {r.marijuana_use} % of age group: {r.age} years used marijuana {int(r.marijuana_frequency)} number of times (median)') app_log.trace(f'QUERY:{msg}') print() msg = "Highest Percentage of those in a age group who used cocaine in the past 12 months" print(msg) print() data = research.highest_cocaine_use() for idx, r in enumerate(data[:5],1): print(f'{idx}. {r.cocaine_use} % of age group: {r.age} years used cocaine {int(r.cocaine_frequency)} number of times (median)') app_log.trace(f'QUERY:{msg}')
def main(): profiler.enable() # init research.init() hot_days = research.get_hot_days() cold_days = research.get_cold_days() wet_days = research.get_wettest_days() profiler.disable() # print the 5 hottest days print('5 Hottest days') for day in hot_days[:5]: print(f'{day.actual_max_temp}F on {day.date}') # print the 5 coolest dates print() print('5 Coldest days') for day in cold_days[:5]: print(f'{day.actual_min_temp}F on {day.date}') # print the wettest dates print() print('5 Wettest days') for day in wet_days[:5]: print(f'{day.actual_precipitation} inches on {day.date}')
def main(): print("Weather research for Seattle, 2014-2015") print() # TODO: Initialize the data research.init() #print(research.data) print("The hottest 5 days:") days = research.hot_days() #TODO: Show the days, creating a function that gives the hottest 5 days for idx, d in enumerate(days[:5]): print("{}. {} F on {}".format(idx + 1, d.actual_max_temp, d.date)) print() print("The coldest 5 days:") days = research.cold_days() #TODO: Show the days for idx, d in enumerate(days[:5]): print("{}. {} F on {}".format(idx + 1, d.actual_min_temp, d.date)) print() print("The wettest 5 days:") #TODO: Show the days days = research.wet_days() # TODO: Show the days for idx, d in enumerate(days[:5]): print("{}. {} F on {}".format(idx + 1, d.actual_precipitation, d.date))
def main(): print('Initialize the data.') # TODO: initialize csv file. research.init() print() print('-' * 50) print('Top five countries that consume the most beer:') beer_countries = research.sort_beer(research.data) for i, record in enumerate(beer_countries[:5], 1): print("{}. {} consumes {} servings of beer per year.".format( i, record.country, record.beer_servings)) print() print('Top five countries that consume the most spirits:') spirit_countries = research.sort_spirit(research.data) for i, record in enumerate(spirit_countries[:5], 1): print("{}. {} consumes {} servings of spirit per year.".format( i, record.country, record.spirit_servings)) print() print('Top five countries that consume the most wine:') wine_countries = research.sort_wine(research.data) for i, record in enumerate(wine_countries[:5], 1): print("{}. {} consumes {} servings of wine per year.".format( i, record.country, record.wine_servings))
def main(): print(f'Weather data for Seattle, 2014-2015') print() # Initialize the data research.init() print('The hottest 5 days:') days = research.hot_days() for idx, d in enumerate(days[:5]): print(f'#{idx + 1}, {d.actual_max_temp} F on {d.date}') print() print('The coldest 5 days:') days = research.cold_days() for idx, d in enumerate(days[:5]): print(f'#{idx + 1}, {d.actual_min_temp} F on {d.date}') print() print('The wettest 5 days:') days = research.wet_days() for idx, d in enumerate(days[:5]): print( f'#{idx + 1}, {d.actual_precipitation} inches of rain on {d.date}')
def main(): print("Drug Use Data") print() research.init()
def main(): print("Weather research for Seattle, 2014-2015") print() research.init() print('The hottest 5 days:') days = research.hot_days() for idx, d in enumerate(days[:5]): print("{}. {} F on {}".format(idx + 1, d.actual_max_temp, d.date)) print() print('The coldest 5 days:') days = research.cold_days() for idx, d in enumerate(days[:5]): print("{}. {} F on {}".format(idx + 1, d.actual_min_temp, d.date)) print() print('The wettest 5 days:') days = research.wet_days() for idx, d in enumerate(days[:5]): print("{}. {} inches of rain on {}".format(idx + 1, d.actual_precipitation, d.date))
def main(): print('Alcohol Consumption Worldwide...') research.init() print('Countries that drink the most') drink_most = research.drink_most() for idx, drink in enumerate(drink_most[:5],1): print(f"{idx} : {drink.country} - {drink.total_litres_of_pure_alcohol}") print('Countries that drink the least') drink_least = research.drink_least() for idx, drink in enumerate(drink_least[:5],1): print(f"{idx} : {drink.country} - {drink.total_litres_of_pure_alcohol}") print('Countries that drink the least - non-zero') drink_least = research.drink_nonzero_least() for idx, drink in enumerate(drink_least[:5], 1): print(f"{idx} : {drink.country} - {drink.total_litres_of_pure_alcohol}") print('Countries that drink the most spirits') drinks = research.most_spirits() for idx, drink in enumerate(drinks[:5], 1): print(f"{idx} : {drink.country} - {drink.spirit_servings} servings") print('Countries that drink the least spirits') drinks = research.least_spirits() for idx, drink in enumerate(drinks[:5], 1): print(f"{idx} : {drink.country} - {drink.spirit_servings} servings") print('Countries that drink the least spirits') drinks = research.least_nonzero_spirits() for idx, drink in enumerate(drinks[:5], 1): print(f"{idx} : {drink.country} - {drink.spirit_servings} servings")
def main(): print("Weather research for Seattle, 2014-2015") print() profiler.enable() research.init() hot_days = research.hot_days() cold_days = research.cold_days() wet_days = research.wet_days() profiler.disable() print("The hottest 5 days:") for idx, d in enumerate(hot_days[:5]): print("{}. {} F on {}".format(idx + 1, d.actual_max_temp, d.date)) print() print("The coldest 5 days:") for idx, d in enumerate(cold_days[:5]): print("{}. {} F on {}".format(idx + 1, d.actual_min_temp, d.date)) print() print("The wettest 5 days:") for idx, d in enumerate(wet_days[:5]): print("{}. {} inches of rain on {}".format(idx + 1, d.actual_precipitation, d.date))
def main(): # TODO: load the CSV file # TODO: Ask an input question # TODO: Output a 'region' appropriate answer. print('Earthquake data for San Andreas') print() research.init() print() print('End. ')
def main(): # merge_data.merge_data() research.init() print('') print('Here are the suburbs with the lowest number of complaints') for i in research.safest_suburbs(): print(f'{i[0]} has {i[1]} food safety complaints') print('') print('Here are the suburbs with the highest number of complaints') for i in research.sickest_suburbs(): print(f'{i[0]} has {i[1]} food safety complaints')
def main(): research.init() print("Applicant Research") print() print("The top cities.") top_cities = research.top_cities(4) print(top_cities) print("The top companies.") top_companies = research.top_companies(3) print(top_companies)
def main(): research.init() # Ask region regions = research.get_list_regions() region_id = ask_for_region(regions) # Ask money moneys_ranges = research.get_moneys_ranges() money_id = ask_for_household_budget(moneys_ranges) research.print_others_meals_choice(regions[region_id], moneys_ranges[money_id])
def main(): research.init() print('\n\n Regions:\n') regions = research.get_regions() for k, v in regions.items(): print(f'({k}).{v}') region = regions.get(int(input('Please select the region: '))) print('\n\nIncomes\n') incomes = research.get_income_ranges() for k, v in incomes.items(): print(f'({k}).{v}') income = incomes.get(int(input('Please select the income range: '))) research.output_region_appropriate_menu_of_five_items(region, income)
def __call__(self): profiler.enable() research.init() matched_candy = [] while True: # inp = input( # "Please enter, one category at a time, what kind of candy you like (pick from: chocolate, fruity, " # "caramel, peanutyalmondy, nougat, crispedricewafer, hard, bar. Type 'f' when finished.\n>>> ") self.categories = ['chocolate', 'caramel'] inp = 'f' try: if self._check_first_input(inp) is 'f': break except ValueError as ve: print(ve) continue self._get_matched_candy() while True: inp = 'single' # using predefined values to eliminate input skew # inp = input("Do you prefer [single] candies, or ones that include [multiple] in one package?\n>>> ") try: if self._check_second_input(inp): print(self.matched_candy) self._get_matched_candy() break except ValueError as ve: print(ve) continue sorted_candy = research.sort_matched_candy_by('winpercent', self.matched_candy) top_five = research.get_top_five_candy(sorted_candy) if top_five: print( "Below is a list of the top matching candies, based on your selections:" ) for idx, candy in enumerate(top_five, 1): print(f"{idx}. {candy.competitorname}") else: print( "Unfortunately, it seems no candy in our database matches your preference." ) profiler.disable()
def main(): research.init() print('Breakdown of post-Sandy 311 calls') print() print('Top 5 days for total calls') days = research.call_days() for idx, row in enumerate(days[:5], 1): print(f'{idx}. {row.date}: {row.total}') print() print('Top 5 days for FEMA-associated calls.') days = research.fema_calls() for idx, row in enumerate(days[:5], 1): print(f'{idx}. {row.date}: {row.FEMA}') print() research.day_lookup()
def main(): print('Weather Data Analysis start') research.init() #To Do: Read CSV file days = research.get_hottest_days() # Get top 5 hottest days for idx, day in enumerate(days[:5]): print( f'{idx+1}. {day.date} is hottest day with {day.actual_max_temp} F') print() days = research.get_coldest_days() for idx, day in enumerate(days[:5]): print( f'{idx+1}. {day.date} is coldest day with {day.actual_max_temp} F') #Get top 5 clod days pass
def main(): print("Weather research data for Seattle, 2014-2015") print() research.init('nyc.csv') hot_days = research.hot_days() cold_days = research.cold_days() wet_days = research.wettest_days() print('======================================') print("The 5 hottest days:") for idx, d in enumerate(hot_days[:5], 1): print(f"{idx}. {d.date}: {d.actual_max_temp}F") print('======================================') print("The 5 coldest days:") for idx, d in enumerate(cold_days[:5], 1): print(f"{idx}. {d.date}: {d.actual_min_temp}F") print('======================================') print("The 5 wettest days:") for idx, d in enumerate(wet_days[:5], 1): print(f"{idx}. {d.date}: {d.actual_precipitation}in")
def main(): print("Weather research for Seattle, 2014-2015") print() research.init() print("The hottest 5 days:") days = research.hot_days() for idx, day in enumerate(days[:5], 1): print(f'{idx}. {day.actual_max_temp} on {day.date}') print() print("The coldest 5 days:") days = research.cold_days() for idx, day in enumerate(days[:5], 1): print(f'{idx}. {day.actual_min_temp} on {day.date}') print() print("The wettest 5 days:") days = research.wet_days() for idx, day in enumerate(days[:5], 1): print(f'{idx}. {day.actual_precipitation} on {day.date}') print()
def main(): print("Weather research for Seattle, 2014-2015") print() research.init() print("The hottest 5 days: ") days = research.hot_days() for idx, d in enumerate(days[:5], start=1): print(f"{idx}. {d.actual_max_temp} F on {d.date}") print() print("The coldest 5 days: ") days = research.cold_days() for idx, d in enumerate(days[:5], start=1): print(f"{idx}. {d.actual_min_temp} F on {d.date}") print() print("The wettest 5 days: ") days = research.wet_days() for idx, d in enumerate(days[:5], start=1): print(f"{idx}. {d.actual_precipitation} inches of rain on {d.date}") print()
def companies_div_over_4(data): return [company for company in data if company.DividendYield >= 4.00] def companies_close_to_WeekLow(data): # Let's say close is a 10% over it or less. return [ company for company in data if company.WeekLow >= 0.95 * company.Price ] if __name__ == '__main__': profiler.enable() research.init() profiler.disable() print('---------------') print('Companies under 50$:') print() for company in companies_under_50(research.data): print(f'{company.Symbol}: {company.Price}') print() print('Companies with div yield over 4:') print() for company in companies_div_over_4(research.data): print(f'{company.Symbol}: {company.DividendYield}') print() print(len(companies_close_to_WeekLow(research.data))) for company in companies_close_to_WeekLow(research.data): print(f'{company.Symbol}: {company.Price} - {company.WeekLow}')
def main(): print('Netflix Show Data from Netflix_Titles.csv') print() research.init()
def main(): print('Starting...') research.init()