In [5]:
from IPython.display import Image
Image(filename='IPy_header.png')
Out[5]:
In [6]:
Image(filename='jupyter-logo.png')
Out[6]:
In [ ]:
In [ ]:
In [2]:
%matplotlib inline
In [8]:
import matplotlib.pyplot as pl
import numpy
x = numpy.linspace(0, 100)
y = x**3
pl.plot(x, y, label='Curve', color='black')
pl.yscale('log')
pl.legend(loc=4)
pl.show()
In [9]:
def distance_modulus (distance):
return 2.5*numpy.log(distance)
distance_modulus(400)
Out[9]:
In [11]:
def distance (apparent, absolute):
log_distance = (apparent - absolute + 5)/5
return 10**(log_distance)
distance(12.34, -24.75)
Out[11]:
In [13]:
cepheid_apparent = numpy.linspace(11, 18)
cepheid_absolute = numpy.linspace(-21, -29)
distance(cepheid_apparent, cepheid_absolute)
Out[13]:
In [14]:
cepheid_distances = distance(cepheid_apparent, cepheid_absolute)
pl.plot(cepheid_distances, cepheid_absolute)
pl.gca().invert_yaxis()
pl.xlabel('Distance')
Out[14]:
In [15]:
class A(object):
def __init__(self):
self.x = 'Hello'
def method_a(self, y,z):
print self.x + ' ' + y + z
a = A()
a.method_a('everbody!', 'Bye')
ndksnvanskncklansvjkdsvkl
In [26]:
class Galaxy:
def __init__(self, sfr, mass):
self.sfr = sfr
self.mass = mass
gal1 = Galaxy(1.0, 1e12)
gal2 = Galaxy(3.0, 2e12)
def some_operation(gal):
return gal.mass / gal.sfr
print some_operation(gal1)
print some_operation(gal2)
In [ ]: