临近ddl的总体复习计划
明天就是考试日,考试时间为12:00-13:30,时间为一个半小时
可复习的时间大约为12小时,分为现在(下午)、晚上、明天早晨
当前暂定计划:
- 文件编辑大作业复习(预计下午完成)
- ppt上实例更改题设并复现(预计下午完成)
- GUI编程复习(预计晚上完成)
- 所有知识点梳理(有时间就做)
文件编辑大作业复习
题目1
将file1.txt文件中的每行按逆序方式输出到file2.txt文件中
程序
f1 = open("F:\\Pythontry\\file1.txt","r")
f2 = open("F:\\Pythontry\\file2.txt","w")
count1 = len(f1.readlines())
#print(count1)
f1.seek(0)
for i in range(0,count1):
inp = f1.readline()
# print(inp)
inp = inp.replace("\n","")
count2 = len(inp)
# f2.write("\n")
for j in range(1,count2+1):
f2.write(inp[-j])
if j == (count2):
f2.write("\n")
f1.close()
f2.close()
timing
30min
完整写出,排错所用时间略长
编写过程中遇到问题
- range()函数使用不熟练
range(start,stop[,step])
解决办法:用即时窗口实验编程
实例:
1)正序使用
for i in range(0,3):
print(i)
输出结果:
0
1
2
2)用for语句使字符串倒序输出
string = "123456"
for i in range(1,len(string)+1):
print(string[-i],end="")
输出结果:
654321
3) 在文件编辑中使单行文本倒序输出
运用不太经典的IPO方法编写
f1 = open("F:\\Pythontry\\file1.txt","r")
f2 = open("F:\\Pythontry\\file2.txt","w")
inp = f1.readline()
inp = inp.replace("\n","")
count = len(inp)
for i in range(1,count+1):
f2.write(inp[-i])
f1.close()
f2.close()
- 对应数据类型的函数调用不熟练
具体表现在背不出调用函数的名称、不能正确拼写(大概是个手残_(:з)∠))
解决办法:顺便复习一下ppt的上班部分内容呗(:з)∠)_
- 一行输出后进行回车的写入
正确输入方法:
……
if i == count:
f2.write("\n")
错误方法:
……
f2.write("\n")
不能正确运行的原因在于for语句执行的次序问题,没有时间深究了
题目2
scores.txt文件存放着某班学生的计算机课成绩,包含学号、平时成绩、期末成绩三列。
请根据平时成绩占40%,期末成绩占60%的比例计算总评成绩,并按学号、总评成绩两列写入另一个文件scored.txt中。
同时在屏幕上输出学生总人数,按总评成绩计算90分以上、80-89分、70-79分、60-69分、
60分以下各成绩区间的人数和班级总平均分(取小数点后两位)
程序
f1 = open("F:\\pythontry\\scores.txt","r")
f2 = open("F:\\pythontry\\scored.txt","w")
f1.readline()
inp = f1.readlines()
s = len(inp)
ave = s1 = s2 = s3 = s4 = s5 = 0
for i in inp:
i = i.split()
score = round(0.4*float(i[1])+0.6*float(i[2]),2)
# print(score)
f2.write("%s\t%d\n"%(i[0],score))
ave += score
if score >= 90:
s1 += 1
elif score >= 80:
s2 += 1
elif score >= 70:
s3 += 1
elif score >= 60:
s4 += 1
else:
s5 += 1
print("学生总人数:"+str(s))
print("总评成绩90分以上"+str(s1)+"人")
print("总评成绩80-89分"+str(s2)+"人")
print("总评成绩70-79分"+str(s3)+"人")
print("总评成绩60-69分"+str(s4)+"人")
print("总评成绩60分以下"+str(s5)+"人")
ave = round(ave/s,2)
print("班级总平均分:"+str(ave)+"分")
f1.close()
f2.close()
timing
20 min
选择了保守的编程方案,还没爆手速,问题不大
总结
比计划完成得慢了一点……
当前进度
- 文件编辑
- 文件编辑大作业复习
- ppt上实例更改题设并复现
- GUI编程复习
- 所有知识点梳理
- 数据及类型
- 语句和流程控制
- 模块化与函数
- 面向对象基础
- 数据结构
- GUI编程