py总结

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</

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值