This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
__author__ = 'Ernest' | |
from fuzzywuzzy import fuzz | |
from fuzzywuzzy import process | |
COMPOUND_LIST = "compounds.txt" | |
wordlist = open(COMPOUND_LIST).readlines() | |
# Get rid of newlines | |
wordlist = [word.lower().strip() for word in wordlist] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] | |
def print_grades(grades): | |
for grade in grades: | |
print grade | |
def grades_sum(grades): | |
total = 0 | |
for grade in grades: | |
total += grade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] | |
def print_grades(grades): | |
for grade in grades: | |
print grade | |
def grades_sum(grades): | |
total = 0 | |
for grade in grades: | |
total += grade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
__author__ = 'Ernest' | |
import urllib2 | |
import re | |
from bs4 import BeautifulSoup | |
packtpub_url = "http://www.packtpub.com/" | |
def get_bookurls(url): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# there are a few erors where the script cannot return the correct number of lines | |
# and the problem with utf-8 encoding | |
# could use the code in scrapePubMed2.py to sort out the encoding issue? | |
__author__ = 'Ernest' | |
from bs4 import BeautifulSoup | |
import urllib2 | |
import re |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
__author__ = 'Ernest' | |
def is_leap_year(x): | |
if x % 4 == 0 and x % 100 != 0: | |
print "%r was a leap year" % x | |
elif x % 400 == 0: | |
print "%r was a leap year" % x | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
__author__ = 'Ernest' | |
import math | |
def distance(x1, y1, x2, y2): | |
dx = x2 - x1 | |
dy = y2 - y1 | |
dsquared = dx**2 + dy**2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# encoding: utf-8 | |
""" | |
Created: 22/07/15, 14:02 | |
Description: return the median value from a sorted list of numbers, | |
an odd length list will have the median value at the centre | |
an list with an even set of numbers will have the median at n and n-1 | |
In the online exercise you need to use 2.0 in the division to get the floating point number. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
from bottle import route, run, debug, template, request, static_file, error | |
# only needed when you run Bottle on mod_wsgi | |
from bottle import default_app | |
@route('/todo') | |
def todo_list(): | |
conn = sqlite3.connect('todo.db') |