Skip to content

Instantly share code, notes, and snippets.

@Tehnix
Last active December 28, 2015 07:29
Show Gist options
  • Select an option

  • Save Tehnix/7464493 to your computer and use it in GitHub Desktop.

Select an option

Save Tehnix/7464493 to your computer and use it in GitHub Desktop.
Random Facts
from sys import argv
from urllib2 import urlopen
from os.path import exists
URL = "http://numbersapi.com/random"
SCRIPT, TO_FILE = argv
print "Top 5 Facts of The World"
with open(TO_FILE, 'w') as out_file:
for n in range(5):
data = urlopen(URL).read()
print "\n%s). %s " % (n+1, data)
out_file.write(data + '\n')
print "\nNow, let us save the facts to a file for future use."
print "Alright, facts are saved in the repo."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment