In the first seminar we only cover some python basics. For more infromation on variable types, lists and plotting with matplotlib see the following links:
Important Variable Types in Python (string, integer and float)
a = "cat"
b = 1
c = 1.2332432
print a
print b
print c
print a[1], a[1:], a[::-1]
print b*b, b+1, b*10
print b/10 # <----
print b/10.
converting types
numberstring = "2313"
numberinteger = int(numberstring)
numberfloat = float(numberstring)
print numberstring
print numberinteger
print numberfloat
List of strings
dobutsu = ["cat", "dog", "bird"]
print dobutsu
dobutsu[1]
dobutsu+dobutsu
dobutsu + ["board"]
List of Integers
EmptyList = []
print EmptyList
EmptyList.append(2)
print EmptyList
EmptyList.append(10)
print EmptyList
numbers = [1,2,3,4,3]
print numbers
numbers + [2]
len(numbers)
NewNumbers = range(1,11)
print NewNumbers
for miau in NewNumbers:
print miau + 1
X = range(100)
print X
Y = []
print Y
for i in X:
Y.append(i**2)
print Y
import pylab as plt
plt.plot(X[::10],Y[::10])
plt.plot(X,X)
plt.xlabel("X-Axis")
plt.ylabel("Y-Axis")
plt.title("Boring Plot")
plt.savefig("firstplot.png") #### saving the plot
plt.show() #### printing the plot
plt.scatter(X[::10],Y[::10],Y[::10])
plt.xlabel("X-Axis")
plt.ylabel("Y-Axis")
plt.title("Boring Plot")
plt.savefig("firstplot.png") #### saving the plot
plt.show()
We will talk more about plotting and fitting next week