摘要: 实验任务3; from turtle import * def square(size=50, rgb='pink'): '''绘制正方形 参数size指定边长 参数rgb指定画笔颜色 如果没有给参数,采用默认值 ''' pencolor(rgb) for i in range(4): fd(siz 阅读全文
posted @ 2022-06-12 15:55 刘封云 阅读(12) 评论(1) 推荐(0) 编辑
摘要: class User: def __init__(self, name, password='111111', status='1'): self.name = name self.password = password self.status = status def info(self): if 阅读全文
posted @ 2022-06-02 10:59 刘封云 阅读(9) 评论(1) 推荐(0) 编辑
摘要: 实验任务3: def is_valid(line): if len(line)==18: if line.isdigit() or line[-1]=='X': return True else: return False else: return False with open('data3_id 阅读全文
posted @ 2022-05-19 11:15 刘封云 阅读(17) 评论(2) 推荐(0) 编辑
摘要: 实验任务3: with open('data3.txt','r',encoding='utf-8')as f: t=f.readlines() p=[] for i in t: if t[0]==i: y='原始数据'+'\t'+'四舍五入后数据'+'\n' p.append(y) else: y= 阅读全文
posted @ 2022-05-15 19:40 刘封云 阅读(35) 评论(1) 推荐(0) 编辑
摘要: 试验任务1: print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) 这4处使用的标识符sum是代表一个变量名吗?如果不是,请分别指出这4行 阅读全文
posted @ 2022-05-04 22:43 刘封云 阅读(32) 评论(1) 推荐(0) 编辑
摘要: 恢复内容开始 实验任务1: import random print('用列表存储随机整数: ') ls = [random.randint(1, 100) for i in range(5)] print(ls) print('\n用集合存储随机整数: ') s1 ={random.randint( 阅读全文
posted @ 2022-04-24 16:41 刘封云 阅读(28) 评论(3) 推荐(0) 编辑
摘要: 实验任务1: task1.py x = list(range(10)) print('整数输出1: ', end = '') for i in x: print(i, end=' ') print('\n整数输出2: ', end = '') for i in x: print(f'{i:02d}' 阅读全文
posted @ 2022-04-06 22:53 刘封云 阅读(28) 评论(3) 推荐(0) 编辑
摘要: 实验任务1:task1_1.py#print输出的几种用法 #用法1:用于输出单个字符或单个变量 print('hey,u') #用法2:用于输出多个数据项,用逗号分隔 print('hey,u') x,y,z=1,2,3 print(x,y,z) #用法3:用户混合字符串与变量值 print('x 阅读全文
posted @ 2022-03-23 19:57 刘封云 阅读(65) 评论(2) 推荐(0) 编辑