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 urlparse | |
import urllib | |
def add_param_to_url(url, param, val): | |
parsed = urlparse.urlsplit(url)._asdict() | |
query = urlparse.parse_qs(parsed['query']) | |
query[param] = [val] | |
parsed['query'] = urllib.urlencode(query, True) | |
return urlparse.urlunsplit(urlparse.SplitResult(**parsed)) |
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
concordance = dict() | |
def tokenize(line): | |
return line.split(" ") | |
def feed(line): | |
words = tokenize(line) | |
for word in words: | |
if word not in concordance: | |
concordance[word] = 0 |
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
def tokenize(line): | |
return line.split(" ") | |
def feed(concordance, line): | |
words = tokenize(line) | |
for word in words: | |
if word not in concordance: | |
concordance[word] = 0 | |
concordance[word] += 1 |
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 re | |
import random | |
def vtoc_idx(s): | |
match_obj = re.search(r'[aeiou][^aeiou]', s.lower()) | |
if match_obj: | |
return match_obj.start() + 1 | |
else: | |
return None |
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
Holyoake Glossary Of English to nominate "Jacquefe" for Word of the Month | |
Australian Nomenclature Institute to nominate "Automanlv" for Word of the Century | |
Ogilvie Lexicon Of North American English advances "Ol33T" as Word of the Year | |
Roget Glossary Of International English to nominate "San Dieydg" for Word of the Decade | |
Practical English Thesaurus selects "Buffet Mop" as Word of the Week | |
Royal British English Dictionary names "Doufml" Word of the Fortnight | |
Central Board Of Orthography to select "Toory Quinto" as Word of the Century | |
Heritage Association Of Vocabulary to advance "Hiking Irt" as Word of the Century | |
United States Global English Dictionary to declare "Concert Happie" Word of the Week | |
Coleridge English Lexicon to pick "Ignof Practice" as Word of the Year |
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
(1) create a program that prints every other line of input. | |
i.e., if you ran the program like so: | |
$ python every_other_line.py <sea_rose.txt | |
it would produce the output | |
Rose, harsh rose, | |
meagre flower, thin, | |
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
# vim:fileencoding=utf8 | |
print u"🐱" | |
print u"\U0001F431" |
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 30 columns, instead of 29 in line 9.
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
Rk,G,Date,Age,Tm,,Opp,,GS,MP,FG,FGA,FG%,3P,3PA,3P%,FT,FTA,FT%,ORB,DRB,TRB,AST,STL,BLK,TOV,PF,PTS,GmSc,+/- | |
1,1,2013-10-29,28-303,MIA,,CHI,W (+12),1,38:01,5,11,.455,0,1,.000,7,9,.778,0,6,6,8,1,0,2,0,17,16.9,+8 | |
2,2,2013-10-30,28-304,MIA,@,PHI,L (-4),1,36:38,9,17,.529,4,7,.571,3,4,.750,0,4,4,13,0,0,4,3,25,21.4,-8 | |
3,3,2013-11-01,28-306,MIA,@,BRK,L (-1),1,42:14,11,19,.579,1,2,.500,3,5,.600,1,6,7,6,2,1,5,2,26,19.9,-3 | |
4,4,2013-11-03,28-308,MIA,,WAS,W (+10),1,34:41,9,14,.643,3,5,.600,4,5,.800,0,3,3,5,1,0,6,2,25,17.0,+16 | |
5,5,2013-11-05,28-310,MIA,@,TOR,W (+9),1,36:01,13,20,.650,1,3,.333,8,8,1.000,2,6,8,8,0,1,1,2,35,33.9,+3 | |
6,6,2013-11-07,28-312,MIA,,LAC,W (+5),1,37:09,6,13,.462,1,3,.333,5,9,.556,0,5,5,6,1,0,4,4,18,10.8,-1 | |
7,7,2013-11-09,28-314,MIA,,BOS,L (-1),1,36:32,9,13,.692,0,0,,7,9,.778,1,7,8,10,0,0,5,1,25,23.1,+5 | |
8,8,2013-11-12,28-317,MIA,,MIL,W (+23),1,29:58,13,21,.619,4,7,.571,3,6,.500,0,3,3,2,0,0,3,0,33,21.6,+14 | |
9,9,2013-11-15,28-320,MIA,,DAL,W (+6),1,36:58,14,18,.778,1,1,1.000,10,11,.909,0,6,6,4,1,0,6,0,39,31. |
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
17,25,26,25,35,18,25,33,39,30,13,21,22,35,28,27,26,23,21,21,24,17,25,30,24,18,38,19,33,26,26,15,30,32,32,36,25,21,34,30,29,27,18,34,30,24,31,13,37,36,42,33,31,20,61,22,19,17,23,19,21,24,43,15,25,32,38,17,13,32,17,34,38,29,37,36,27 |
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
X is a cleric. Its university is Y (http://dbpedia.org/ontology/EducationalInstitution). | |
X is a ship. Its ship draft (μ) is Y (http://www.w3.org/2001/XMLSchema#double). | |
X is a legislature. Its region served is Y (http://dbpedia.org/ontology/Place). | |
X is a dog. Its foal date is Y (http://www.w3.org/2001/XMLSchema#date). | |
X is a lake. Its area total (m2) is Y (http://www.w3.org/2001/XMLSchema#double). | |
X is a automobile engine. Its piston stroke (μ) is Y (http://www.w3.org/2001/XMLSchema#double). | |
X is a Painting. Its original title is Y (http://www.w3.org/2001/XMLSchema#string). | |
X is a speedway league. Its location city is Y (http://dbpedia.org/ontology/City). | |
X is a governmental administrative region. Its iso code of a province is Y (http://www.w3.org/2001/XMLSchema#string). | |
X is a murderer. Its waist size (μ) is Y (http://www.w3.org/2001/XMLSchema#double). |