3+2
print(2**3)
(3+5)-(2-1)
x = 2
print (x)
x = 3
print (x)
x = 3.6789
print (x)
my_num = 99
my_str = "luft ballons"
print (my_num, my_str, x)
x
x + 3
x + my_num
z = x+my_num
print (z)
def addtwo(myVar):
print(myVar+2)
addtwo(3)
addtwo(5)
addtwo(x)
%pylab inline
mySum(3, 0.1)
def mySum(x, y):
z = x+y
print (z)
mySum(3, .1)
z = mySum(3,.1)
print (z)
def mySum(x, y):
return x+y # return the value of x+y
z = mySum(3, .1)
print (z)
print (mySum(3, .1))
print(x)
x = 3
cos(x)
print (cos(2*pi*x))
print (floor(2.6893567))
print (ceil(2.576787))
sqrt(floor(2.567))
def getDecimal(var1, var2):
return var1/var2 - floor(var1/var2)
def getRemainder(var1, var2):
return getDecimal(var1, var2)*var2
print (getDecimal(3,2))
print (getRemainder(3,2))
plot([1,2,3,4], [-1, 4, 7, .1], 'ro',linewidth=5)
myList = [1,2]
myList = ['hello', 2, .1, -1]
myList.append("goodbye")
print(myList)
myList.remove(2)
print(myList)
myList.insert(3, "yay")
print (myList)
help insert
help(insert)
nameList=['youngsun', 'janet', 'aleksandra', 'tayshana']
print(nameList)
nameList.append("laura")
print (nameList)
nameList[3]
nameList.remove('janet')
nameList[0]
print(len(nameList))
print (nameList[len(nameList)-1])
print (nameList[4])
newList = [1, 2]
print(newList[1])
(): used in declaring, calling functions; math order of operations []: used to declare a list; access an element of the list
newList[1]
print(newList)
newList.remove(2)
print(newList)
z = newList[1]
print(z)
newList = [1,2,3]
del newList[1]
print(newList)
xList = [1,2,3]
yList1 = [4,5,6]
yList2 = [1,2,3]
plot(xList, yList1, "go-", linewidth=2)
plot(xList, yList2, 'r+-', linewidth=5)
xs = array([0,1,2,3])
xs = [0,1,2,3]
print (xs+3)
xs = array([0,1,2,3])
print (xs+3)
ys = xs+3
xs = linspace(-5,5, 200) # create an array from -5 to 5 with 200 equally spaced values
myGauss = exp(-xs**2)
plot(xs, myGauss, 'r', label="a gaussian plot!")
legend()
xlabel("my x")
ylabel('my y')
myX = array([0, 1, 2, 3, 4])
myY = myX**2
print(myY[4])
plot(myX, myY)
mat = array([[1,2,3],[10,11,12]])
print (mat)
print(mat[1][2])
myRow = mat[0, :]
print(myRow)
myCol = mat[:,0]
print (myCol)