Created
June 6, 2020 09:10
-
-
Save gonzalodiaz/8ea72bbf776cccc5ec21b64b13a7cdfb to your computer and use it in GitHub Desktop.
NumpyStyle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class World: | |
"""Class to contain the properties of the World. | |
Parameters | |
---------- | |
yearly_population : dict | |
World's population by year | |
Attributes | |
---------- | |
yearly_population :dict | |
Internal attribute to hold the world population. | |
""" | |
def __init__(self, yearly_population): | |
self.yearly_population = yearly_population | |
def population(self, year): | |
"""Obtain the population in the world for a given year. | |
Parameters | |
---------- | |
year : int | |
Year of which the population wants to be known. | |
Returns | |
------- | |
Population for that year. 0 if the year was not found. | |
""" | |
return self.yearly_population.get(year, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment