CS21 Lab 8: Example Output

This is output from a large run of a working program.

  • It includes examples of each menu option, some menu options selected more than one time. Note that

  • It includes examples of handling bad input values from the user (not necessarily handling every case).

  • It shows examples of output printed in tabular format that your solution should mimic.

User input is shown in bold.

$ python3 climate.py
There are data for 193 countries in this file

========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 9
  9 is not a valid choice, try again
Enter a value between 1 and 6: -4
  -4 is not a valid choice, try again
Enter a value between 1 and 6: 1
Enter one of 1960 or 2020 for the year: 2000
  2000 is not a valid value, try again
Enter one of 1960 or 2020 for the year: -5
  -5 is not a valid value, try again
Enter one of 1960 or 2020 for the year: 1960

---- Population in 1960 ----
lowest:       0.00438 M in Nauru
highest:    667.07000 M in China

========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 2
Enter a year (one of 1960, 1980, 2000, 2020, 2022): 2023
  2023 is not a valid value, try again
Enter a year (one of 1960, 1980, 2000, 2020, 2022): -8
  -8 is not a valid value, try again
Enter a year (one of 1960, 1980, 2000, 2020, 2022): 1999
  1999 is not a valid value, try again
Enter a year (one of 1960, 1980, 2000, 2020, 2022): 1960
Enter a lower CO2 limit value
Enter a value between 0 and 20000: 500

      Country                1960 CO2 emissions > 500.0000 Mt
---------------------------------------------------------------
 China                                        798.7999
 European Union (27)                         2099.3709
 Germany                                      813.9502
 Russia                                       884.5549
 United Kingdom                               584.0200
 United States of America                    2897.3153

========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 2
Enter a year (one of 1960, 1980, 2000, 2020, 2022): 2022
Enter a lower CO2 limit value
Enter a value between 0 and 20000: 500

      Country                2022 CO2 emissions > 500.0000 Mt
---------------------------------------------------------------
 Canada                                       547.9439
 China                                      11396.7774
 European Union (27)                         2761.9071
 Germany                                      665.6047
 India                                       2829.6442
 Indonesia                                    728.8833
 Iran                                         690.6353
 Japan                                       1053.7979
 Mexico                                       511.9720
 Russia                                      1652.1773
 Saudi Arabia                                 662.5494
 South Korea                                  600.9993
 United States of America                    5057.3038

========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 3
Enter one of 1960 or 2020 for the year: 3
  3 is not a valid value, try again
Enter one of 1960 or 2020 for the year: 1960

---------- largest per GDP in 1960
  Luxembourg                           16.3480/B

========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 4
Enter one of 1960 or 2020 for the year: 1960
Enter population lower bound in millions of people
Enter a value between 0 and 8000: 100

  Country                    1960  Population > 100.000000 M
----------------------------------------------------------
 China                                     667.070000
 European Union (27)                       356.906098
 India                                     450.547675
 Russia                                    119.897000
 United States of America                  180.671000

========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 4
Enter one of 1960 or 2020 for the year: 4
  4 is not a valid value, try again
Enter one of 1960 or 2020 for the year: 2020
Enter population lower bound in millions of people
Enter a value between 0 and 8000: 100

  Country                    2020  Population > 100.000000 M
----------------------------------------------------------
 Bangladesh                                164.689383
 Brazil                                    212.559409
 China                                    1411.100000
 Egypt                                     102.334403
 Ethiopia                                  114.963583
 European Union (27)                       447.479493
 India                                    1380.004385
 Indonesia                                 273.523621
 Japan                                     126.261000
 Mexico                                    128.932753
 Nigeria                                   206.139587
 Pakistan                                  220.892331
 Philippines                               109.581085
 Russia                                    144.073139
 United States of America                  331.501080

========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 5

Enter the name of a country: Mexico

Mexico
  1960 pop:    37.771861  2020 pop:   128.932753
  1960 GDP:    13.040000  2020 GDP:  1087.117783
          1960         1980         2000         2020         2022
     63.052300   267.743800   391.725000   442.289100   511.972000

========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 5

Enter the name of a country: India

India
  1960 pop:   450.547675  2020 pop:  1380.004385
  1960 GDP:    37.029884  2020 GDP:  2667.687952
          1960         1980         2000         2020         2022
    111.325100   291.711100   977.526400  2421.552300  2829.644200

========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 5

Enter the name of a country: hello tehre

Sorry, hello tehre is not in the database


========  Menu Options: ========
1. country w/lowest and country w/highest population in given year
2. list all countries with CO2 above some value for a given year
3. country with largest C02 per GDP for a given year
4. countries with population larger than given value for given year
5. print a country's info
6. quit

Select a menu option
Enter a value between 1 and 6: 6
bye bye