python学习笔记01

python学习笔记01,第1张

概述if<条件>:  语句elif<条件>:  语句else: 语句for  ainb:  语句else: 语句berakcontinuepassbreakdef 函数名(参数): 语句\return aa<bandb>c数值计算库:numpy+scipy(Fortran数值计算库)=matlab符号计算库:sympy绘图及可视化:matplotli

if <条件>:

    语句

elif<条件>:

   语句

else:

 语句

for   a in b:

   语句

else:

  语句

berak continue pass break

def  函数名(参数):

  语句 \

return  a

a<b and b>c

数值计算库:numpy+scipy(Fortran数值计算库)=matlab

符号计算库:sympy

绘图及可视化: matplotlib

a[起始:终点:步长]

@R_404_5565@ numpy as nppersontype = np.dtype({'names':['name', 'age', 'weight'],'formats':['S32','i', 'f']})a = np.array([("Zhang",32,75.5),("Wang",24,65.2)],dtype=persontype)+ - * / //整除 ** power % 求余def triangle_wave(x, c, c0, hc):x = x - int(x) # 三角波的周期为1,因此只取x坐标的小数部分进行计算if x >= c: r = 0.0elif x < c0: r = x / c0 * hcelse: r = (c-x) / (c-c0) * hcreturn rx = np.linspace(0, 2, 1000)y = np.array([triangle_wave(t, 0.6, 0.4, 1.0) for t in x])len(a)a.shape>>> a = np.arange(12).reshape(2,3,2)>>> b = np.arange(12,24).reshape(2,2,3)>>> c = np.dot(a,b)>>> np.save("a.npy", a)>>> c = np.load( "a.npy" )>>> carray([[ 0, 1, 2, 3],[ 4, 5, 6, 7],[ 8, 9, 10, 11]])from scipy.optimize @R_404_5565@ fsolve2 from math @R_404_5565@ sin,cos34 def f(x):5 x0 = float(x[0])6 x1 = float(x[1])7 x2 = float(x[2])8 return [9 5*x1+3,10 4*x0*x0 - 2*sin(x1*x2),11 x1*x2 - 1.512 ]>>> @R_404_5565@ matplotlib.pyplot as plt>>> fig = plt.figure()>>> ax = fig.add_axes([0.15, 0.1, 0.7, 0.3])>>> fig = plt.figure()>>> fig.show()>>> fig.patch.set_color("g")>>> fig.canvas.draw()result = fsolve(f, [1,1,1])print result print f(result)

 

总结

以上是内存溢出为你收集整理的python学习笔记01全部内容,希望文章能够帮你解决python学习笔记01所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1184829.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存