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 smallest_divisor(n): | |
div=2 | |
while n%div!=0: | |
div = div+1 | |
return div | |
print "Smallest divisor of",2011,"is",smallest_divisor(2011) |
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
# http://richard.cgpublisher.com/product/pub.84/prod.11 | |
# INTIALISATION | |
import pygame, math, sys | |
from pygame.locals import * | |
TURN_SPEED = 5 | |
ACCELERATION = 2 | |
MAX_FORWARD_SPEED = 10 | |
MAX_REVERSE_SPEED = 5 | |
BG= (0,0,0) |
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
# http://richard.cgpublisher.com/product/pub.84/prod.11 | |
# INTIALISATION | |
import pygame, math, sys, random | |
from pygame.locals import * | |
TURN_SPEED = 5 | |
ACCELERATION = 2 | |
MAX_FORWARD_SPEED = 10 | |
MAX_REVERSE_SPEED = 5 | |
BG= (0,0,0) |
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
class Farm: | |
def __init__(self): | |
self.animals = [] | |
def add(self, animal): | |
self.animals.append(animal) | |
def __str__(self): | |
s = '' | |
for animal in self.animals: |
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
class Multimap: | |
def __init__(self): | |
'''Create an empty Multimap''' | |
self.inner = inner | |
def get(self, key): | |
'''Return list of values associated with key''' | |
return self.inner.get(key, []) | |
def count(self, key): |
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 BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | |
from time import asctime | |
from socket import gethostbyname, gethostname | |
import cgi | |
# http://fragments.turtlemeat.com/pythonwebserver.php | |
class MyHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
the_time = asctime() | |
self.wfile.write('Time: '+ the_time) |
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 swampy.Gui import * | |
def go(): | |
g.la(text=entry.get()) | |
g=Gui() | |
g.title('My GUI') | |
entry = g.en(text="Enter text here") | |
button = g.bu(text="Go", command=go) | |
label = g.la() |
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 swampy.Gui import * | |
def go(): | |
g.la(text=text.get(0.0,END)) | |
text.delete(0.0,END) | |
g=Gui() | |
g.title('My GUI') | |
text = g.te(width=50, height=5) |
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
bla |
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
{ | |
"metadata": { | |
"name": "ma_analysis" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
OlderNewer