Skip to Content
Learn Python by Building Data Science Applications
book

Learn Python by Building Data Science Applications

by Philipp Kats, David Katz
August 2019
Beginner
482 pages
12h 56m
English
Packt Publishing
Content preview from Learn Python by Building Data Science Applications

Writing the Island class

Next, let's describe the islands our animals will live on. Each island here is an isolated system that tracks all the changes, including the death and birth of all the animals, ever-changing conditions, and so on. For our purposes, these islands will also need to collect stats on the animals.

Let's start small by defining attributes of each island:

  • A list of animals currently living on the island
  • Current year (turn)
  • Maximum population cap (integer)
  • Umbrella object for all the statistics

The preceding attributes are defined in the following code snippet:

class Island: stats = dict() animals = list()    max_pop, year = 0, 0      def __init__(self, initial_pop=10, max_pop=2500):        self.year = 0        self.max_pop = max_pop self.stats ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for Data Science

Python for Data Science

Yuli Vasiliev
Introduction to Machine Learning with Python

Introduction to Machine Learning with Python

Andreas C. Müller, Sarah Guido

Publisher Resources

ISBN: 9781789535365Supplemental Content