示例#1
0
def main():
    while True:
        try:
            user_input_year = input(
                'Please enter a year between 1800 and 2012: ')
            if user_input_year == 'finish':
                sys.exit(0)
            try:
                user_year = int(user_input_year)
                if user_year < 1800 or user_year > 2012:
                    raise ValueError
                year = read_and_display_GDP(user_year)
                year.generate_income_barchart()

                for i in range(2007, 2013):
                    example_year = data_analysis_graphs(i)
                    example_year.generate_merged_income_histogram()
                    example_year.generate_merged_income_boxplot()
            except ValueError:
                print('Invalid input. Please try again: ')

        except ValueError:
            print('Invalid input. Please try again:')
        except KeyboardInterrupt:
            sys.exit(0)
 def test_read_and_display_GDP_class(self):
     with self.assertRaises(ValueError):
         read_and_display_GDP(1799)
     with self.assertRaises(ValueError):
         read_and_display_GDP(2013)
     with self.assertRaises(ValueError):
         read_and_display_GDP('abc')
 def test_read_and_display_GDP_class(self):
     with self.assertRaises(ValueError):
         read_and_display_GDP(1799)
     with self.assertRaises(ValueError):
         read_and_display_GDP(2013)
     with self.assertRaises(ValueError):
         read_and_display_GDP('abc')
示例#4
0
def main():
    while True:
        try:
            user_input_year = input('Please enter a year between 1800 and 2012: ')
            if user_input_year == 'finish':
                sys.exit(0)
            try:
                user_year = int(user_input_year)
                if user_year < 1800 or user_year > 2012:
                    raise ValueError
                year = read_and_display_GDP(user_year)
                year.generate_income_barchart()

                for i in range(2007,2013):
                    example_year = data_analysis_graphs(i)
                    example_year.generate_merged_income_histogram()
                    example_year.generate_merged_income_boxplot()
            except ValueError:
                print('Invalid input. Please try again: ')

        except ValueError:
            print('Invalid input. Please try again:')
        except KeyboardInterrupt:
            sys.exit(0)