Skip to content

Instantly share code, notes, and snippets.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3t3+VaQwviqMwjLyRYCIvc2pyMo9G5hamc9Aj2TYsZsFO6imfyyM4amaenlrGkMOMXke6ZJNRJ4Uv6xdDzD74cmF9NS66flEL0fBTVIiuhrr1d/qvNY7Zu7XWxKvXMcMmfm2x2pDQfRGKcOfr6A2r8MZ+SWkhASdo2zZYNzBETfgICmhGsl/+qCFshbgH1mmngCA2w9qUXPf6P3a4ZOBu8wg8gJ0xt+7oA5rXiSqTl3biZ5z9pyIL99JIABnvNwDwbVZPbPIEv37/wZNV0yLrDMqCeV1EjlflyurMCTydJE8h3Bhex6lX2w0stsx9TnP0niJJFE7JnCHR1e2ooqZr [email protected]
grade = input("What was the grade? ")
if grade >= 0 and grade <=39:
print("Fail.")
elif grade >= 40 and grade <= 59:
print("Pass.")
elif grade >= 60 and grade <= 79:
print("Merit.")
elif grade >= 80 and grade <=100:
print("Distinction.")
# Download a dictionary
# see https://stackoverflow.com/questions/18834636/random-word-generator-python
from urllib.request import urlopen
import random
wordsURL = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain"
response = urlopen(wordsURL)
wordList = response.read().splitlines()
import socket
import random
import threading
class game:
def __init__(self):
self.number = random.randint(1, 30)
def guess(self, number):
distance = abs(self.number - number)
@Telltak
Telltak / matrix_test.py
Created October 22, 2012 20:15
Testing Matrices in Python
matrix = [[0, 1, 2, 3], [1, 0, 5, 6], [2, 5, 0, 4], [3, 6, 4, 0]]
print "A to C"
print matrix[0][2]
print "D to B"
print matrix[3][1]
print " |A|B|C|D"
print "A|%d|%d|%d|%d" % (matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0])
print "B|%d|%d|%d|%d" % (matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1])
print "C|%d|%d|%d|%d" % (matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2])
@Telltak
Telltak / 17.py
Created January 15, 2012 18:50
Trying to shorten exercise 17 to one line. (broken)
a=lambda f, m:open(__import__('sys').argv[f],m);if not raw_input("File %d bytes\nEnter continue, CTRL-C abort." % len(a(1, 'r').read())):a(2, 'w').write(a(1, 'r'))
print "Format Characters:"
print "d OR i: int"
print "o: octal"
print "x: lowercase hex"
print "X: uppercase hex"
print "f OR F: float"
print "c: single char"
print "r: String (using repr())"
print "s: String (using str())"
print "So you want to call a baby ugly?"
def parent(parent):
print "If the {0} strong or able to beat you up?".format(parent)
print "Say N if you're not sure"
answer=raw_input("Y or N: ")
if answer == "Y":
return True
else:
return False
father=parent("father")
@Telltak
Telltak / oh_hai_thur.py
Created May 21, 2011 08:35
A pointless script.
from sys import argv
if len(argv)>1 and argv[1].isdigit():
r = ''
for i in range(int(argv[1])):
r+='r'
print "oh hai thu{0}".format(r)
else:
print "Please supply a positive integer as an argument"
Earthquake.init do
output do |item|
next unless item["_stream"]
if "#{item["text"]}".match(/@leegeorg07/)
notify "#{item["user"]["screen_name"]}: #{item["text"]}"
end
end
end