上午: Python程序设计
老师此次课程教学for回圈, List comprehension, 产生器, 例外处理(try、except), 函式function
for回圈
list_y = [ [1, -2, 0],[2, -5, 3],[-2, -3,0]]
x = 0
for i in list_y:
for j in i:
if j<0:
x = x +j
print(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 = 0
for 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) + 32
Fahrenheit(20)
下午: 人工智慧与机器学习概论
今日延续上次php的部分,此次结合highchart呈现资料视觉化最後呈现画面
>>: 解决Windows总是把Typescript文件夹看成影音档
WannaCry 还没逆完,把最後一天的内容拿出来挡一下。请读者见谅XD 今天不会讲解技术,会推荐基...
Golang Gin路由 Gin本身是支援restful的,所以可以看一下github所写的范例,使...
大家好,又到了美好的周末 在Day 8、Day 9 时,我们已经透过 Data Collection...
-1. 序 OK,资料分析做完了, 现在要进入演算法的部分, 我们未来几天将从经典卷积神经网路架构中...
前言 你使用过Prototype,那你知道它可以被污染吗? 正文 概念 Javascript的物件透...