摘要: 恢复内容开始 from turtle import * def square(size=50, rgb='pink'): '''绘制正方形 参数size指定边长 参数rgb指定画笔颜色 如果没有给参数,采用默认值 ''' pencolor(rgb) for i in range(4): fd(siz 阅读全文
posted @ 2022-06-13 19:56 天天三顿 阅读(7) 评论(1) 推荐(0) 编辑
摘要: class User: def __init__(self, name, password='111111', status='1'): # 构造新账户 self.name = name self.password = password self.status = status def info(s 阅读全文
posted @ 2022-06-07 20:46 天天三顿 阅读(7) 评论(3) 推荐(0) 编辑
摘要: 实验任务3: def is_valid(x): a=['0','1','2','3','4','5','6','7','8','9','X'] if len(x)==18: x1=x[:17] if x1.isdigit(): for i in x: x2=[] x2.append(i) if x[ 阅读全文
posted @ 2022-05-24 17:04 天天三顿 阅读(21) 评论(3) 推荐(0) 编辑
摘要: task3: with open('data3.txt','r',encoding='utf-8') as f1: data=f1.read().split('\n') x=[eval(i) for i in data[1:]] print(f'原始数据:\n{x}') y=[round(i) fo 阅读全文
posted @ 2022-05-16 22:20 天天三顿 阅读(6) 评论(3) 推荐(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) 截图: 实践任务2.2: list1 = [1, 9, 8, 4] p 阅读全文
posted @ 2022-05-10 23:03 天天三顿 阅读(3) 评论(1) 推荐(0) 编辑
摘要: 实验任务1: import random print('\n用集合存储随机整数:') ls=[random.randint(1,100) for i in range(5)] print(ls) print('\n用集合存储随机整数:') s1={random.randint(1,100) for 阅读全文
posted @ 2022-04-26 20:28 天天三顿 阅读(22) 评论(2) 推荐(0) 编辑
摘要: 实验任务1: 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}',end='-') print('\n整 阅读全文
posted @ 2022-04-11 17:03 天天三顿 阅读(29) 评论(4) 推荐(0) 编辑
摘要: task1_1: print('hey,u') print('hey','u') x,y,z=1,2,3 print(x,y,z) print('x=%d,y=%d,z=%d'%(x,y,z)) print('x={},y={},z={}'.format(x,y,z)) print(f'x={x}, 阅读全文
posted @ 2022-03-28 17:39 天天三顿 阅读(39) 评论(3) 推荐(0) 编辑