except ValueError: print ("Error") continue except KeyboardInterrupt: sys.exit(0) except EOFError: sys.exit(0) #Q6 # without asking, the program will continue run the boxplot and histogram plot for the requested year # use pre-define the merge_year class to handle the merged year function year_generate = [2007,2008,2009,2010,2011,2012] for int_input_year in year_generate: analysis_year_merged_data = merge_year(income, countries, int_input_year) data_analysis = data_analysis_tools(analysis_year_merged_data.result(), int_input_year) data_analysis.plot() # almost the same as the pervious block, the block handles input and use pre-define data_analysis_tools class # details are in the data_analysis_tools class while True: try: input_year = input("Any other year want to explore? Or type finish: ") if input_year.upper() == str("FINISH"): break try: int_input_year = int(input_year) if int_input_year not in year_list: print ("Input is not in the range") continue
def test_database_index(self): self.assertEqual(merge_year(income, countries, 1902).result().shape,(277,3)) pass