• Create your own version of the Mayoral Excuse Machine in Python that takes in a name and location, selects an excuse at random and prints an excuse (“Sorry, Richard, I was late to City Hall to meet you, I had a very rough night and woke up sluggish”)
  • Use the “excuses.csv” in the Github repository
  • Extra credit if you print the link to the story as well

In [7]:
import pandas as pd
import numpy as np
excuses=pd.read_csv('/home/sean/git/algorithms/class1/homework/data/excuse.csv')

In [31]:
name=input('Tell me your name -')
destination=input('Now tell me where you would like to go -')
pick=np.random.choice(excuses.index)
excuse=excuses['excuse'][pick]
source=excuses['hyperlink'][pick]
full_excuse=("Sorry, {name}, I was late to {destination} to meet you, {excuse}.\nThis excuse brought to you by {source}").format(
                name=name, destination=destination, excuse=excuse, source=source)
print(full_excuse)


Tell me your name -dfsgsf
Now tell me where you would like to go -weggf
Sorry, dfsgsf, I was late to weggf to meet you, we had some stuff we had to do.
This excuse brought to you by http://www.dnainfo.com/new-york/20150307/belle-harbor/de-blasio-30-minutes-late-rockaway-st-patricks-day-parade

In [ ]: