2021-2022-1 20211418 《信息安全專業導論》第七周學習總結
作業信息
[2021-2022-1信息安全專業導論](https://edu.cnblogs.com/campus/besti/2021-2022-1fois)
[2021-2022-1信息安全專業導論第七周作業](http://www.rzrgm.cn/rocedu/p/9577842.html#WEEK07)
教材學習內容總結
- 閱讀《計算機科學概論》第8章(抽象數據類型與子程序),了解了棧,隊列,列表,樹圖等的概念,學習了子程序和參數的概念。
- 閱讀《看漫畫學Python》第8、11章(函數、常用的內置模塊),了解了多種函數類型,和幾種常用的官方提供模塊。
教材學習中的問題和解決過程
問題1: 近期Python內容比較抽象,閱讀完教材都還覺得不太理解
問題1解決方案: 自己嘗試運用在Python中學到的內容編寫程序解決問題,如果能正常運行且結果正確,就可以慢慢熟練掌握。
代碼調試過程中的問題和解決過程
問題1:在打一長串代碼的時候很容易出錯,而且不知道錯在了哪里
問題1解決方案: 注意自己的排版,比如分段中間空一行等。當出現錯誤時可以參考給出的英語提示在相應位置尋找錯誤??梢宰约嚎偨Y自己常犯的錯誤,比如我現在很容易多打一個字母和忘記換行。
代碼托管
def rect_area(width, height):
area = width * height
return area
def print_area(width,height):
area = width * height
print("{0} x {1}長方形的面積:{2}".format(width,height,area))
def rect_area(width, height):
area = width * height
return area
r_area = rect_area(320,480)
print("{0} x {1} 長方形的面積:{2:.2f}".format(320,480,r_area))
def rect_area(width, height):
area = width * height
return area
r_area = rect_area(width=320,height=480)
print("{0} x {1} 長方形的面積:{2:.2f}".format(320,480,r_area))
r_area = rect_area(height=480,width=320)
print("{0} x {1} 長方形的面積:{2:.2f}".format(320,480,r_area))
def make_coffee(name='Cappuccino'):
return "Make a {0}".format(name)
coffee1 = make_coffee("Latte")
coffee2 = make_coffee()
print(coffee1)
print(coffee2)
def sum(*numbers):
total = 0.0
for number in numbers:
total += number
return total
print(sum(100.0,20.0,30.0))
print(sum(30.0,80.0))
x=20
def print_value():
x = 10
print('函數中x={0}'.format(x))
print_value()
print("全局變量x={0}".format(x))
x=20
def print_value():
global x
x = 10
print('函數中x={0}'.format(x))
print_value()
print("全局變量x={0}".format(x))
def add(a,b):
return a + b
def sub(a,b):
return a - b
def calc(opr):
if opr == '+':
return add
else:
return sub
f1 = calc('+')
f2 = calc('-')
print("10 + 5 ={0}".format(f1(10,5)))
print("10 - 5 = {0}".format(f2(10,5)))
def add(a,b):
return a + b
def sub(a,b):
return a - b
def square(a):
return a*a
def calc(opr):
if opr == '+':
return add
else:
return sub
f1 = calc('+')
f2 = calc('-')
print("10 + 5 ={0}".format(f1(10,5)))
print("10 - 5 = {0}".format(f2(10,5)))
def f1(x):
return x > 50
data1 = [66,15,91,28,98,50,7,80,99]
filtered = filter(f1,data1)
data2 = list(filtered)
print(data2)
def f1(x):
return x*2
data1 = [66,15,91,28,98,50,7,80,99]
mapped = map(f1,data1)
data2 = list(mapped)
print (data2)
def calc(opr):
if opr == '+':
return lambda a,b:(a + b)
else:
return lambda a,b:(a - b)
f1 = calc('+')
f2 = calc('-')
print("10+5={0}".format(f1(10,5)))
print("10-5={0}".format(f2(10,5)))
data1 = [66,15,91,28,98,50,7,80,99]
filtered = filter(lambda x:(x > 50),data1)
data2 = list(filtered)
print(data2)
mapped = map(lambda x:(x * 2),data1)
data3 = list(mapped)
print(data3)
import math
print(math.ceil(2.4))
print(math.floor(2.4))
print(math.ceil(-2.4))
print(math.floor(-2.4))
print(math.pow(5,3))
print(math.sqrt(3.6))
print(math.log(125,5))
print(math.degrees(0.5*math.pi))
print(math.radians(180/math.pi))
print(math.sin(0.3))
import datetime
d = datetime.datetime(2020,1,29)
print(d)
d = datetime.datetime(2020,1,29,23,56,59,10000)
print(d)
import datetime
print(datetime.datetime.today())
print(datetime.datetime.now())
print(datetime.datetime.fromtimestamp(999999999.999))
import datetime
d = datetime.date(2020,2,29)
print(datetime.date.today())
print(datetime.date.fromtimestamp(999999999.999))
import datetime
print(datetime.time(23,59,58,1999))
import datetime
d = datetime.date.today()
print(d)
delta = datetime.timedelta(10)
d += delta
print(d)
d = datetime.date(2020,1,1)
delta = datetime.timedelta(weeks = 5)
d -= delta
print(d)
import datetime
d = datetime.datetime.today()
print(d.strftime('%Y-%m-%d %H:%M:%S'))
print(d.strftime('%Y-%m-%d'))
str_date = '2020-02-29 10:40:25'
date = datetime.datetime.strptime(str_date,'%Y-%m-%d %H:%M:%S')
print(date)
import re
p = r'\w+@zhijieketang.com'
email1 = 'tony_guan588@zhijieketang.com'
m = re.match(p,email1)
print(type(m))
print(m)
email2 = 'tony_guan588@163.com'
m = re.match(p,email2)
print(m)
import re
p = r'\w+@zhijieketang.com'
text = "Tony's email is tony_guan588@zhijieketang.com."
m = re.search(p,text)
print(m)
text = "Tony's email is tony_guan588@163.com."
m = re.search(p,text)
print(m)
p = r'Java|java|JAVA'
text = 'I like Java and java and JAVA.'
match_list = re.findall(p,text)
print(match_list)
import re
p = r'\d+'
text = 'AB12CD34EF'
replace_text = re.sub(p,' ',text)
print(replace_text)
replace_text = re.sub(p,' ',text,count = 1)
print(replace_text)
replace_text = re.sub(p,' ',text,count = 2)
print(replace_text)
import re
p = r'\d+'
text = 'AB12CD34EF'
clist = re.split(p,text)
print(clist)
clist = re.split(p,text,maxsplit = 1)
print(clist)
clist = re.split(p,text,maxsplit = 2)
print(clist)
上周考試錯題總結
暫無。
其他
最近Python內容難度也在變大,要花時間自己進行練習。
學習進度條
| | 代碼行數(新增/累積)| 博客量(新增/累積)|學習時間(新增/累積)|重要成長|
| 第一周 | 200/200 | 2/2 | 20/20
| 第二周 | 200/400 | 2/4 | 20/40
| 第三周 | 200/600 | 2/6 | 20/60
| 第四周 | 200/800 | 2/8 | 20/80
| 第五周 | 200/1000 | 2/10 | 20/100
| 第六周 | 200/1200 | 1/11 | 20/120
| 第七周 | 200/1400 | 1/12 | 20/140
|
參考資料
《計算機科學概論》《看漫畫學Python》
posted on
浙公網安備 33010602011771號