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
#!/usr/bin/env python3 | |
import tkinter as tk | |
import numpy as np | |
from numpy import sin, cos, sqrt | |
G = 6.67384e-11 # m^3 kg-1 s-2 | |
DEG = np.pi / 180 | |
AU = 1.49597871e11 # for converting to meters | |
METRE = 1 / 1.49597871e11 # for converting to AU |
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
#!/usr/bin/env python3 | |
#Usbourne Computer Battlegames was a type-in computer games book | |
#from the 1980s. | |
#This is a version of "Battle at Traitors Castle" game. | |
#Original BASIC by Daniel Isaaman and Jenny Tyler | |
import curses |
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
#!/usr/bin/env python3 | |
# Usbourne Computer Space Games was a type-in computer games book | |
# from the 1980s. This is a version of "Moonlander" game. | |
# Original BASIC by Daniel Isaaman and Jenny Tyler | |
from time import sleep | |
print(chr(27) + "[2J") # Clear screen | |
print("Moonlander") | |
#Set the starting values |
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
import turtle as t | |
xstart = 3.2 | |
ystart = 0 | |
xend = 4 | |
yend = 1 | |
xstep = 0.5*(xend-xstart)/t.screensize()[0] | |
convergesteps = 100 |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import datetime as dt | |
import numpy | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import matplotlib.dates as md | |
import locale | |
from functools import reduce | |
locale.setlocale(locale.LC_ALL, "") |
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
#!/usr/bin/env python3 | |
import random | |
import os | |
import sys | |
""" | |
Mentalist Poker http://www.benefactum.ca/?p=274 | |
1. Each player starts with 20 chips or counters of some sort, a screen to hide | |
them, and a “betting line,” perhaps a piece of string or a pencil, placed | |
horizontally in front of him (but behind the screen). Chips placed in front of |
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
#Find a minecraft stronghold | |
#To find a stronghold you need an eye of ender, which you throw into the air. | |
#Make a note of your current location and the direction in which the eye goes. | |
#You can find these from the F3 debug screen. | |
#Move to a second point (it should be reasonably distant from the first) | |
#Throw the eye again and note the second point and direction. Enter | |
#the numbers below and run. It outputs the location of the stronghold. |
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
#!/usr/bin/env python3 | |
#Use: LoveCalculator.py "Katy Perry" "Justin Bieber" | |
import sys | |
import itertools | |
def pairwise(iterable): | |
"s -> (s0,s1), (s1,s2), (s2, s3), ..." | |
a, b = itertools.tee(iterable) | |
next(b, None) | |
return zip(a, b) |
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
This gist provides a web page (time.php) that contains an image that is updated hourly. | |
It is intended to be used with a directory of images with hashed filenames, generated by renameseq.py and shafile.py, and the event server timesse.php to make a "slow movie", rather like xkcd.com/time. | |
The php file are put on the web server, and the python files can be put somewhere that python will find them. They should work ok in python2. |
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
#!/usr/bin/env python3 | |
## Example of using the jqmath library. | |
import cgi | |
from multipletest import Quiz | |
mathsq= Quiz("Trig quiz") |
OlderNewer