In [13]:
# Test 1

#!/Users/slayer/Software/Install/anaconda2/bin/python

import EstNumJellyBeans as jelly

# Get a jelly bean estimator
estimator = jelly.NumJellyEstimator()

# Set the fraction of land being used for sugar, the world population,
# and the fraction of the population that loves pink.
land_frac = 0.1
ppl = "7 billion"
pink_frac = 0.18
estimator.set_land_frac_for_sugar(land_frac)
estimator.set_world_pop(ppl)
estimator.set_frac_ppl_loving_pink(pink_frac)

# Get the estimate of the number of jelly beans in the world,
# and report the result given the input.
est = estimator.compute_Njelly_est()

print ("\nIt is estimated that when\n", land_frac*100, "percent\nof the land is"+\
      " used for sugar and\n", pink_frac*100, "percent of", int(ppl), \
      "people\nLOVE pink, then there are\n", est, "\nJelly Beans in the world.")


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-13-2b7557244eed> in <module>()
     12 pink_frac = 0.18
     13 estimator.set_land_frac_for_sugar(land_frac)
---> 14 estimator.set_world_pop(ppl)
     15 estimator.set_frac_ppl_loving_pink(pink_frac)
     16 

/Users/macuser/NE24/JellyBeanCodeHW5/JellyBeanCode/EstNumJellyBeans.py in set_world_pop(self, people)
     47         # NE24: Add a test for type here
     48         assert type(people) is int, \
---> 49             "Error: population must be an integer."
     50 
     51         # NE24: Add a test for value here

AssertionError: Error: population must be an integer.

In [21]:
# Test 2

#!/Users/slayer/Software/Install/anaconda2/bin/python

import EstNumJellyBeans as jelly

# Get a jelly bean estimator
estimator = jelly.NumJellyEstimator()

# Set the fraction of land being used for sugar, the world population,
# and the fraction of the population that loves pink.
land_frac = 0.1
ppl = 10
pink_frac = 0.18
estimator.set_land_frac_for_sugar(land_frac)
estimator.set_world_pop(ppl)
estimator.set_frac_ppl_loving_pink(pink_frac)

# Get the estimate of the number of jelly beans in the world,
# and report the result given the input.
est = estimator.compute_Njelly_est()

print ("\nIt is estimated that when\n", land_frac*100, "percent\nof the land is"+\
      " used for sugar and\n", pink_frac*100, "percent of", int(ppl), \
      "people\nLOVE pink, then there are\n", est, "\nJelly Beans in the world.")


Error: There are approximately 7 Billion people in the world
An exception has occurred, use %tb to see the full traceback.

SystemExit
/Users/macuser/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2889: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

In [17]:
# Test 3

#!/Users/slayer/Software/Install/anaconda2/bin/python

import EstNumJellyBeans as jelly

# Get a jelly bean estimator
estimator = jelly.NumJellyEstimator()

# Set the fraction of land being used for sugar, the world population,
# and the fraction of the population that loves pink.
land_frac = 0.1
ppl = 7000000000
pink_frac = 5
estimator.set_land_frac_for_sugar(land_frac)
estimator.set_world_pop(ppl)
estimator.set_frac_ppl_loving_pink(pink_frac)

# Get the estimate of the number of jelly beans in the world,
# and report the result given the input.
est = estimator.compute_Njelly_est()

print ("\nIt is estimated that when\n", land_frac*100, "percent\nof the land is"+\
      " used for sugar and\n", pink_frac*100, "percent of", int(ppl), \
      "people\nLOVE pink, then there are\n", est, "\nJelly Beans in the world.")


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-17-b1c66435593e> in <module>()
     15 estimator.set_land_frac_for_sugar(land_frac)
     16 estimator.set_world_pop(ppl)
---> 17 estimator.set_frac_ppl_loving_pink(pink_frac)
     18 
     19 # Get the estimate of the number of jelly beans in the world,

/Users/macuser/NE24/JellyBeanCodeHW5/JellyBeanCode/EstNumJellyBeans.py in set_frac_ppl_loving_pink(self, frac)
     63         # NE24: Add a test for type here
     64         assert type(frac) is float, \
---> 65             "Error: fraction of land set must be a float."
     66 
     67         # NE24: Add a test for value here

AssertionError: Error: fraction of land set must be a float.

In [20]:
# Test 4

#!/Users/slayer/Software/Install/anaconda2/bin/python

import EstNumJellyBeans as jelly

# Get a jelly bean estimator
estimator = jelly.NumJellyEstimator()

# Set the fraction of land being used for sugar, the world population,
# and the fraction of the population that loves pink.
land_frac = 0.1
ppl = 7000000000
pink_frac = 0.0
estimator.set_land_frac_for_sugar(land_frac)
estimator.set_world_pop(ppl)
estimator.set_frac_ppl_loving_pink(pink_frac)

# Get the estimate of the number of jelly beans in the world,
# and report the result given the input.
est = estimator.compute_Njelly_est()

print ("\nIt is estimated that when\n", land_frac*100, "percent\nof the land is"+\
      " used for sugar and\n", pink_frac*100, "percent of", int(ppl), \
      "people\nLOVE pink, then there are\n", est, "\nJelly Beans in the world.")


Error: There should be at least one person who loves pink.
An exception has occurred, use %tb to see the full traceback.

SystemExit
/Users/macuser/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2889: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: