Skip to content

Instantly share code, notes, and snippets.

@gonzalodiaz
Created June 6, 2020 09:09
Show Gist options
  • Save gonzalodiaz/3c894a1fa14f14233a11b731bb4fd644 to your computer and use it in GitHub Desktop.
Save gonzalodiaz/3c894a1fa14f14233a11b731bb4fd644 to your computer and use it in GitHub Desktop.
GoogleStyle
class World:
"""Class to contain the properties of the World.
Args:
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.
Args:
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