Day9 职训(机器学习与资料分析工程师培训班): python、 php结合highchart

上午: Python程式设计

老师此次课程教学for迴圈, List comprehension, 产生器, 例外处理(try、except), 函式function
for迴圈

list_y = [ [1, -2, 0],[2, -5, 3],[-2, -3,0]]x = 0for i in list_y:    for j in i:        if j<0:            x = x +jprint(x)

搭配enumerate

#删除奇数位的数字list_x = [1, 3, 5, 0, -1, -3, -2]list_y = list_x.copy()enu_b = enumerate(list_y)for i,j in enu_b:    #print(i,j)    if (i % 2) == 0:        list_x.remove(j)print(list_x)

搭配zip

#计算获利list_a = [52000, 51000, 48000]list_b = [46800, 45900, 43200]profit = 0for i,j in zip(list_a, list_b):    #print(i,j)    profit = profit+ (i-j)print(f'第一季获利: {profit} ' )

List comprehension

list_1 = [1, 2, 3, 4]list_f = [x*x for x in list_1]list_f

搭配if

#删除负值list_1 = [1, 2, 3, 4, -1, -2, -7]list_f = [x*x for x in list_1 if x>0]list_f

产生器(语法类似list生成器)

x = [1, 2, 3, 4]generator_x = (item*item for item in x)for i in generator_x :        print(i)
#产生1-100之间的奇数generator_a = (x for x in range(1,101) if x%2==1)for i in generator_a :        print(i)

例外处理

a = 'b'try:    s = int(a)    # 无法转成数字    print('没有问题')except:    print('发生错误')print('The End')

函式function

输入摄氏温度转换成华氏def Fahrenheit(c):    #c = float(input('请输入摄氏温度'))    return c*(9/5) + 32Fahrenheit(20)

下午: 人工智慧与机器学习概论

今日延续上次php的部分,此次结合highchart呈现资料视觉化最后呈现画面
http://img2.58codes.com/2024/20139039Vq2MCF1Ubn.png


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章