Skip to content

Instantly share code, notes, and snippets.

# name: Mr. McNally
# date: 2016-04-25
# description: Text-based space adventure game
import random
import time
def displayIntro():
print("It is the end of a long year of fighting space criminals")
print("you come to crossroads on your trip home, one path leads home")
# plot F_g vs. separation distance
import numpy
import pylab
m_earth = 5.972e24 #kg
r_earth = 6.371e6 #m
m_person = 80 #kg
G = 6.67408e-11 #m^3 / (kg * s^2)
# average separation between Mars and Earth = 225e9 m
# http://www.universetoday.com/14824/distance-from-earth-to-mars/
@dougmcnally
dougmcnally / random_walk.py
Last active September 11, 2017 19:20
Python code for generating plots of 2D random walks.
import numpy
import pylab
import random
n = 100000
x = numpy.zeros(n)
y = numpy.zeros(n)
for i in range(1, n):
@dougmcnally
dougmcnally / collatz.py
Last active March 6, 2024 19:40
Python code for plotting the number of interations required to reach "1" with the Collatz conjecture iteration process.
# Collatz Conjecture
import matplotlib.pyplot as plt
MAX = 1000000
n_list = range(1,MAX+1)
steps = list()
for n in n_list:
count = 0
while not n == 1:
@dougmcnally
dougmcnally / QHO.py
Last active May 17, 2016 18:13
Source code to generate plots of the Quantum Harmonic Oscillator wavefunction. Here's a brief description of what that is: http://ket.space/index.php/2016/05/17/quantum-harmonic-oscillator/
from __future__ import division
from numpy.polynomial.hermite import *
import numpy
import pylab
import math
# use natural units where c = h_bar = 1
m = 1
w = 1
h_bar = 1
n = 1