View gray.py
This file contains 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
from PIL import Image | |
import os, shutil | |
print "Please enter location of image" | |
input = raw_input('> ') | |
path = os.path.abspath(input) | |
img = Image.open(path) |
View color.py
This file contains 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
favorite_color = raw_input('What\'s your favorite color? ') | |
print "%s is my cousins favorite color too!" % favorite_color | |
raw_input() |
View setup.py
This file contains 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
from setuptools import setup | |
import py2exe | |
setup(console=['color.py']) |
View setup.py
This file contains 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
try: | |
from setuptools import setup | |
except ImportError: | |
from distutils.core import setup | |
import py2exe | |
config = { | |
'description': 'Turn any image to grayscale', | |
'author': 'Ben Awad', | |
'url': 'benawad.com', |
View lexicon.py
This file contains 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
def convert_numbers(s): | |
try: | |
return int(s) | |
except ValueError: | |
return None | |
def scan(sentence): | |
words = sentence.split() | |
sentence = [] | |
for word in words: |
View sample_sentence.py
This file contains 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
"north south east" |
View parser_test.py
This file contains 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
from nose.tools import * | |
from ex48 import parser | |
def test_sentence(): | |
s1 = parser.Sentence(('noun', 'bear'), ('verb', 'kill'), ('direction', 'north')) | |
assert_equal(s1.subject, 'bear') | |
assert_equal(s1.verb, 'kill') | |
assert_equal(s1.object, 'north') | |
def test_peek(): |
View euler22.py
This file contains 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
alphabet = {'"':0,'A':1,'B':2,'C':3,'D':4,'E':5,'F':6,'G':7,'H':8,'I':9,'J':10,'K':11,'L':12,'M':13,'N':14,'O':15,'P':16,'Q':17,'R':18,'S':19,'T':20,'U':21,'V':22,'W':23,'X':24,'Y':25,'Z':26} | |
def name_value(name, pos): | |
sum = 0 | |
for letter in name: | |
sum += alphabet[letter] | |
return sum * pos | |
names_file = open("names.txt") | |
names = names_file.readlines() |
View euler24.py
This file contains 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 itertools | |
nums = [0,1,2,3,4,5,6,7,8,9] | |
perm = list(itertools.permutations(nums)) | |
print perm[999999] |
View euler24_one_line.py
This file contains 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 itertools | |
print list(itertools.permutations([0,1,2,3,4,5,6,7,8,9]))[999999] |
OlderNewer