-
Notifications
You must be signed in to change notification settings - Fork 0
/
CountryApp.py
93 lines (61 loc) · 1.84 KB
/
CountryApp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from Validator import Validator
from Country import Country
china = Country("China", 1415045928)
egypt = Country("Egypt", 99375741)
italy = Country("Italy", 59290969)
turkey = Country("Turkey", 81916871)
russia = Country("Russia", 144500000)
india = Country("India", 1339000000)
canada = Country("Canada", 36710000)
australia = Country("Australia", 24600000)
germany = Country("Germany", 82790000)
countries = [china, egypt, italy, turkey, russia, india, canada, australia, germany]
def printCountries():
for country in countries:
country.displayCountry()
def addCountry():
name = Validator.inputCountry("Enter country name: ")
population = Validator.inputPopulation("enter country population: ")
country = Country(name, population)
countries.append(country)
def byCountry():
countries.sort(key=lambda country: country.countryName)
printCountries()
def byPopulation():
countries.sort(key=lambda country: country.population, reverse=True)
printCountries()
intro_str = """\nThis is a simple population application.
You will be able to see a list of countries alphabetically or
by population and also add to the list of companies\n"""
menu_str = """\n1 - See the list of countries
2 - Add a country
3 - View alphabetically
4 - View by population
5 - Exit\n"""
print(intro_str)
var = 0;
while var != 5:
print(menu_str)
def one():
printCountries()
def two():
addCountry()
def three():
byCountry()
def four():
byPopulation()
def five():
print("Thank you, goodbye")
raise SystemExit
switcher = {
1: one,
2: two,
3: three,
4: four,
5: five
}
def user_choice(arg1):
func = switcher.get(arg1)
return func()
choice = Validator.inputNumber("Selection: ")
user_choice(choice)