2021-2022-1 20211418 《信息安全专业导论》第七周学习总结

作业信息

[2021-2022-1信息安全专业导论](https://edu.cnblogs.com/campus/besti/2021-2022-1fois)
[2021-2022-1信息安全专业导论第七周作业](https://www.cnblogs.com/rocedu/p/9577842.html#WEEK07)

教材学习内容总结

  1. 阅读《计算机科学概论》第8章(抽象数据类型与子程序),了解了栈,队列,列表,树图等的概念,学习了子程序和参数的概念。
  2. 阅读《看漫画学Python》第8、11章(函数、常用的内置模块),了解了多种函数类型,和几种常用的官方提供模块。

教材学习中的问题和解决过程

问题1: 近期Python内容比较抽象,阅读完教材都还觉得不太理解
问题1解决方案: 自己尝试运用在Python中学到的内容编写程序解决问题,如果能正常运行且结果正确,就可以慢慢熟练掌握。

代码调试过程中的问题和解决过程

问题1:在打一长串代码的时候很容易出错,而且不知道错在了哪里
问题1解决方案: 注意自己的排版,比如分段中间空一行等。当出现错误时可以参考给出的英语提示在相应位置寻找错误。可以自己总结自己常犯的错误,比如我现在很容易多打一个字母和忘记换行。

代码托管

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 2021-11-07 20:03  20211418  阅读(28)  评论(0编辑  收藏  举报