Skip to content

Instantly share code, notes, and snippets.

@mikerr
Created August 5, 2013 15:02
Show Gist options
  • Save mikerr/6156601 to your computer and use it in GitHub Desktop.
Save mikerr/6156601 to your computer and use it in GitHub Desktop.
Answers questions from wolfram alpha
#!/usr/bin/python
import wolframalpha
import sys
#Get a free API key here http://products.wolframalpha.com/api/
#I may disable this key if I see lots of abuse
app_id='Q59EW4-7K8AHE858R'
client = wolframalpha.Client(app_id)
query = ' '.join(sys.argv[1:])
res = client.query(query)
print query
if len(res.pods) > 0:
texts = ""
pod = res.pods[1]
if pod.text:
texts = pod.text
else:
texts = "I have no answer for that"
print texts
else:
print "I am not sure"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment