In [1]:
print("Hello World 2!")
In [4]:
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))
In [6]:
def hello(name="NYU student"):
print("Hello %s" %(name))
hello()
hello("Anurag")
In [10]:
animals = []
animals.append("bear")
animals.append("lion")
animals.append("monkey")
animals.append("unicorn")
print(animals)
In [14]:
print(animals[0])
for animal in animals:
print(animal)
In [15]:
a=animals.pop()
print(a)
print(animals)
In [17]:
animals.append("bear")
animals.sort()
print(animals)
In [20]:
animals.append("unicorn")
newlist = [a for a in animals if a!="bear"]
print(newlist)
In [25]:
import random
random.randint(0,10)
Out[25]:
In [26]:
import numpy as np
np.power(2,2)
Out[26]:
In [27]:
from random import *
randint(0,10)
Out[27]:
In [28]:
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()
In [ ]: