Skip to content

Instantly share code, notes, and snippets.

@davekpython
davekpython / homework 5
Created May 12, 2013 19:24
udacity hw 5
import webapp2
import re
import os
import jinja2
import re
import hashlib
import hmac
import random
import string
from google.appengine.ext import db
@davekpython
davekpython / wheel
Created February 5, 2013 16:24
revised wheel.py
from graphics import *
class Wheel():
def __init__(self, center, wheel_radius, tire_radius):
self.tire_circle = Circle(center, tire_radius)
self.wheel_circle = Circle(center, wheel_radius)
def draw(self, win):
self.tire_circle.draw(win)
@davekpython
davekpython / graphics.py
Created February 2, 2013 16:11
mooc a gentle intro to python - animate a wheel
# graphics.py
##"""Simple object oriented graphics library
##
##The library is designed to make it very easy for novice programmers to
##experiment with computer graphics in an object oriented fashion. It is
##written by John Zelle for use with the book "Python Programming: An
##Introduction to Computer Science" (Franklin, Beedle & Associates).
##
##LICENSE: This is open-source software released under the terms of the
##GPL (http://www.gnu.org/licenses/gpl.html).
class OldMaidGame(CardGame):
def play(self, names):
self.deck.removeCard(Card(0,12))
self.hands = []
for name in names:
self.hands.append(OldMaidHand(name))
self.deck.deal(self.hands)
print "----------- Cards have been dealt"
@davekpython
davekpython / hangman
Created January 18, 2013 00:25
this is a version of hangman for the mooc course, a gentle intro to python.
def print_hangman_image(mistakes = 6):
"""Prints out a gallows image for hangman. The image printed depends on
the number of mistakes (0-6)."""
if mistakes <= 0:
print''' ____________________
| .__________________|
| | / /
| |/ /
| | /