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 sys | |
def calcPi(): | |
q, r, t, k, n, l = 1, 0, 1, 1, 3, 3 | |
while True: | |
if 4*q+r-t < n*t: | |
yield n | |
nr = 10*(r-n*t) | |
n = ((10*(3*q+r))//t)-10*n | |
q *= 10 |
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
""" | |
Functions: | |
calc - calculate the specified number of primes starting with 2 | |
findTypes - find the types in the current list of primes | |
""" | |
from math import sqrt | |
primeList = [2] | |
gapList = [] |
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
""" | |
The daemon module implements the support classes for creating daemon processes. | |
Classes: | |
Daemon - base class for constructing a daemon process | |
""" | |
import sys, os, time, atexit | |
from signal import SIGTERM |
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
""" | |
The "sio" module provides support for basic interaction through command-line prompts and input. | |
""" | |
import sys | |
DOT_LEADER = '.' | |
HYP_LEADER = '-' | |
PROMPT_LENGTH = 55 | |
TITLE_CENTER = 30 |
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 sio | |
sio.TITLE_CENTER = 15 | |
sio.PROMPT_LENGTH = 25 | |
sio.print_title('Simple IO Examples') | |
sio.print_newline() | |
sio.print_title('make_float_readable Examples') | |
sio.print_text(sio.make_float_readable(1)) |
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 math | |
import sio | |
import time | |
DATE_DELIMITER = ',' | |
DATE_PROMPT = "Enter a date" | |
DATE_FORMAT = "yr, mo, dy" | |
DATE_HELP = "No help available." | |
DATE_INVALID = "The entered date is invalid!" | |
DATETIME_PROMPT = "Enter a date-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
import unittest | |
import astrodate | |
class Test_Date(unittest.TestCase): | |
def setUp(self): | |
self.lng0 = 64 | |
self.zc0 = 4 | |
self.dst0 = True | |
self.lct0 = (2012, 7, 23, 3, 37, 0, 'lct') |
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 Element(object): | |
"""Used to hold a data item on the Stack.""" | |
def __init__(self, data, next): | |
"""Construct a new Element for the Stack. | |
data: the data to push onto the Stack | |
next: the next Element on the stack | |
""" | |
self.data = data | |
self.next = next |
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 unittest | |
import AlgoStack | |
class Test_AlgoStack(unittest.TestCase): | |
def setUp(self): | |
self.stack = AlgoStack.Stack() | |
def test_push(self): |
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 Element(object): | |
"""Used to hold a data item in the Queue.""" | |
def __init__(self, data, prev): | |
"""Construct a new Element for the Queue. | |
data: the data to add to the Queue | |
prev: the previous Element in the Queue | |
""" | |
self.data = data | |
self.prev = prev |
OlderNewer