In [1]:
print("Hello world!")
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))
In [5]:
print("Out interger is {0}, and our float value is {1}.".format(i, f))
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")
In [8]:
for e in l:
print(e)
In [11]:
c = 0
while c < i:
print(c)
c += 1
In [16]:
def square(i):
return i*i
square(2)
Out[16]:
In [17]:
def power(i,e):
return i**e
power(2,6)
Out[17]:
In [15]:
# Use Lambdas for simple functions
square = lambda x:x*x
square(2)
Out[15]: