Skip to content

Instantly share code, notes, and snippets.

@Ginkgo100
Ginkgo100 / birthday record book.py
Last active January 26, 2017 03:50
Practice Python: Exercise 33. Birthday Dictionary
def makelist(a):
n = a.readline()
n = n.rstrip()
n = n.split("--")
return n
with open("birthday records.txt") as file:
names = makelist(file)
dobs = makelist(file)
file.close()
@Ginkgo100
Ginkgo100 / rx name generator.py
Created January 22, 2017 02:12
Name Generator for Prescription Drugs
#Rx Brand Name Generator by Scivias (Robyn Broyles)
#Each name takes a randomly selected element for its beginning and another for its end. 5 out of 7 times, a third element is selected for the middle.
import random
def readfile(f):
with open(f) as file:
n = file.read()
file.close()
return n.split(",")
print("Draw a grid of any size, up to 32 cells in each direction!")
def checknum(d):
msg = "Please enter a whole number between 1 and 32."
while True:
fin = input("Enter the number of cells " + d + ": ")
try:
fin = float(fin)
except ValueError:
print(msg)
@Ginkgo100
Ginkgo100 / nytimes articles
Created January 10, 2017 03:16
Decode a Webpage (practicepython.org #17)
import requests
from bs4 import BeautifulSoup
def allstories(f):
page=requests.get(f)
soup=BeautifulSoup(page.text,"html.parser")
print("STORIES CURRENTLY ON NYTIMES.COM (in order of appearance):\n")
for art in soup.find_all("h2", class_="story-heading"):