Skip to content

Instantly share code, notes, and snippets.

View ejmurray's full-sized avatar

Ernest Murray ejmurray

  • Leeds, UK
  • 11:35 (UTC -12:00)
View GitHub Profile
@ejmurray
ejmurray / codeObs.py
Created July 18, 2015 10:26
The answer to the codeacademy censor question. Only tested in PyCharm.
def censor(text, word):
word_length = len(word)
print(text)
print(word_length)
censored_word = word_length * '*'
print(censored_word)
separated_text = text.split()
print(separated_text)
update = [censored_word if x == word else x for x in separated_text]
print(update)
wn = turtle.Screen()
#!/usr/bin/env python
__author__ = 'Ernest'
import turtle
wn = turtle.Screen()
wn.bgcolor("lightgreen") # sets the background colour
wn.title("Hello, Ernest!") # set the window title
tess = turtle.Turtle()
@ejmurray
ejmurray / censor.py
Created July 1, 2015 13:33
Put the censored text in the sentence.
#!/usr/bin/python
# encoding: utf-8
"""
Created: 01/07/15, 13:11
Description:
Write a function called censor that takes two strings, text and word, as input.
It should return the text with the word you chose replaced with asterisks.
For example: censor("this hack is wack hack", "hack") should return "this **** is wack ****"
@ejmurray
ejmurray / scrabble.py
Created July 1, 2015 12:09
Updated script to reflect the non console
#!/usr/bin/python
# encoding: utf-8
"""
Created: 01/07/15, 11:14
Description:
Define a function scrabble_score that takes a string word as input and returns the equivalent scrabble
score for that word.
Assume your input is only one word containing no spaces or punctuation.
As mentioned, no need to worry about score multipliers!
#!/usr/bin/python
# encoding: utf-8
"""
Created: 01/07/15, 11:14
Description:
Define a function scrabble_score that takes a string word as input and returns the equivalent scrabble
score for that word.
Assume your input is only one word containing no spaces or punctuation.
As mentioned, no need to worry about score multipliers!
#!/usr/bin/env python
__author__ = 'Ernest'
def scrabble_score():
score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2,
"f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3,
"l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1,
"r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4,
#!/usr/bin/env python
import urllib
import xml.etree.ElementTree as ET
import cgi
import pyperclip
import sys
# TODO: read the xml file of the article in question to figure out where to add the doi.
#!/usr/bin/env python
__author__ = 'Ernest'
import urllib
import xml.etree.ElementTree as ET
import cgi
import pyperclip
import sys
# TODO: read the xml file of the article in question to figure out where to add the doi.
@ejmurray
ejmurray / xml_01.xml
Created June 26, 2015 14:49
cahpter12 for dice into python and XML parsing
<?xml version='1.0' encoding='utf-8'?>
<feed>
<title>dive into mark</title>
<subtitle>currently between addictions</subtitle>
<id>tag:diveintomark.org,2001?07?29:/</id>
<updated>2009?03?27T21:56:07Z</updated>
<link rel='alternate' type='text/html' href='http://diveintomark.org/'/>
<link rel='self' type='application/atom+xml' href='http://diveintomark.org/feed/'/>
<entry>
<author>