In [1]:
for i in range(3):
    print(i)


0
1
2

In [6]:
for i in range(20):
    if i<10:
        print("%d - less than 10" %i)
    elif i==10:
        print("%d - exactly 10" %i)
    else:
        print("%d - greater than 10" %i)


0 - less than 10
1 - less than 10
2 - less than 10
3 - less than 10
4 - less than 10
5 - less than 10
6 - less than 10
7 - less than 10
8 - less than 10
9 - less than 10
10 - exactly 10
11 - greater than 10
12 - greater than 10
13 - greater than 10
14 - greater than 10
15 - greater than 10
16 - greater than 10
17 - greater than 10
18 - greater than 10
19 - greater than 10

In [11]:
def hello(name = "NYU students"):
    print("hello, %s" %name)
    
hello()
hello("ECE students")


hello, NYU students
hello, ECE students

In [12]:
animals = []
animals.append("bear")
animals.append("lion")
animals.append("monkey")
animals.append("unicorn")

print(animals)


['bear', 'lion', 'monkey', 'unicorn']

In [15]:
a = animals.pop(2)

print (a)
print (animals)


monkey
['bear', 'lion', 'unicorn']

In [18]:
animals.append("bear")

animals.count("bear")
animals.insert(2, "monkey")
print (animals)


['bear', 'lion', 'monkey', 'unicorn', 'bear', 'bear']

In [20]:
animals.sort()
print (animals)


['bear', 'bear', 'bear', 'lion', 'monkey', 'unicorn']

In [21]:
import random
random.randint(0,10)


Out[21]:
1

In [22]:
import numpy as np
np.power(2,3)


Out[22]:
8

In [23]:
from random import *
randint(0,10)


Out[23]:
5

In [26]:
import numpy as np
import matplotlib.pyplot as plt
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)

C,S = np.cos(X), np.sin(X)

plt.plot(X,C)
plt.plot(X,S)
plt.show()