Getting Started With Jupyter

What's been done?

  • Installed python
  • Started a Jupyter notebook

Look it Works!


In [1]:
print("Hello world!")


Hello world!

Creating variables in Python


In [10]:
# Integer
i = 4
print(type(i))

# Float
f = 4.0
print(type(f))

# Boolean
b = True
print(type(b))

# String
s = "awesome"
print(type(s))

# Lists
l = [1,2,3,4]
print(type(l))

# Dictionary
d = {'int':1, 'float': 2.0, 'string':'yep', 'boolean':True}
print(type(d))

# None type
n = None
print(type(n))


<type 'int'>
<type 'float'>
<type 'bool'>
<type 'str'>
<type 'list'>
<type 'dict'>
<type 'NoneType'>

Advanced Printing


In [5]:
print("Out interger is {0}, and our float value is {1}.".format(i, f))


Out interger is 4, and our float value is 4.0.

Conditional Statements


In [6]:
if i == 1 and f > 2:
    print("i is equal to 1, and f is greater than 2")
elif i == 1 or f > 2:
    print("Either i is equal to 1 or f is greater than 2")
else:
    print("Neither i is equal to 1 nor f is greater than 2")


Either i is equal to 1 or f is greater than 2

Conditional loops


In [8]:
for e in l:
    print(e)


1
2
3
4

In [11]:
c = 0
while c < i:
    print(c)
    c += 1


0
1
2
3

Functions and Lambdas


In [16]:
def square(i):
    return i*i

square(2)


Out[16]:
4

In [17]:
def power(i,e):
    return i**e

power(2,6)


Out[17]:
64

In [15]:
# Use Lambdas for simple functions 
square = lambda x:x*x
square(2)


Out[15]:
4