type()
mylist[1]=‘five’
My list.append()
len()
mylist[1][2]
Loops:
1.for loop:
for i in range(-2,10,2):
for i in range(len(list)): range就是0到list长度-1
2.while loop:
while x<10:
x+=1
if statement, elif, else
Boolean logic: (the conditional True/False statement) allows you to perform tests that return True or False
A 不等于 B: a != b
A and B: A,B 全对就是T; A or B: 其一正确就是T
% sign: 结果是reminder
Function: def c_b():
Import math
math.degree()
imports the pyplot module from matplotlib:
%matplotlib inline
import matplotlib.pyplot as plt
list 算数 需要用for loop 或者变成array-- np.array():
(1)x1 = [2,4,6,8,10,12,14,16,18]
s=[]
c=[]
for i in range(len(x1)):
s.append(math.sin(x1[i]))
c.append(math.cos(x1[i]))
plt.plot(x1,s,color=‘green’,label=‘sin(x)’)
plt.plot(x1,c,color=‘orange’,label=‘cos(x)’)
plt.legend()
(2)x1 = [2,4,6,8,10,12,14,16,18]
x=np.array(x1)
plt.plot(x1,np.sin(x),color=‘green’,label=‘sin(x)’)
plt.plot(x1,np.cos(x),color=‘orange’,label=‘cos(x)’)
plt.legend()
plt.subplots()
plt.figure()
Make the width of the plot extend from num1 to num2 and height of the plot extend from n3 to n4:
plt.axis([num1,num2,n3,n4])
0~2pi,以0.1增加:
(1)x1=np.arange(0,2np.pi,0.1)
(2)x=[]
i=0.0
while i <= 2</