Last active
June 6, 2020 09:08
-
-
Save gonzalodiaz/b5b95170758550dcdf9bd9fe128cf619 to your computer and use it in GitHub Desktop.
reStructuredText
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. | |
:param yearly_population: World's population by year | |
:type arg: dict | |
:ivar yearly_population: Internal attribute to hold the world population. | |
:vartype yearly_population: dict | |
""" | |
def __init__(self, yearly_population): | |
self.yearly_population = yearly_population | |
def population(self, year): | |
"""Obtain the population in the world for a given year. | |
:param year: Year of which the population wants to be known. | |
:type year: int | |
:returns: Population for that year. 0 if the year was not found. | |
:rtype: int | |
""" | |
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