摘要: from turtle import * def square(size=50, rgb='orange'): '''绘制正方形 参数size指定边长 参数rgb指定画笔颜色 如果没有给参数,采用默认值 ''' pencolor(rgb) for i in range(4): fd(size) le 阅读全文
posted @ 2022-06-14 10:32 稀音络合物 阅读(17) 评论(0) 推荐(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 10:40 稀音络合物 阅读(6) 评论(0) 推荐(0) 编辑
摘要: with open('data3_id.txt', 'r', encoding='utf-8') as f: data=f.readlines() data=[line.strip().split(',') for line in data] ans=[] def isvalid(id): if l 阅读全文
posted @ 2022-05-18 17:24 稀音络合物 阅读(15) 评论(1) 推荐(0) 编辑
摘要: with open('data3.txt','r',encoding='utf-8')as f: data=f.read().strip().split('\n') data[0]='原始数据'+'\t'+'四舍五入后数据'+'\n' for i in range(1,len(data)): dat 阅读全文
posted @ 2022-05-15 16:41 稀音络合物 阅读(30) 评论(1) 推荐(0) 编辑
摘要: print(sum) sum=42 print(sum) def inc(n): sum=n+1 print(sum) return sum sum=inc(7)+inc(7) print(sum) def solve(a, b, c): ''' 求解一元二次方程, 返回方程的两个根 :para: 阅读全文
posted @ 2022-05-11 15:42 稀音络合物 阅读(8) 评论(2) 推荐(0) 编辑
摘要: import random print('用列表存储随机整数: ') ls = [random.randint(1, 100) for i in range(5)] print(ls) print('\n用集合存储随机整数: ') s1 = {random.randint(1,100) for i 阅读全文
posted @ 2022-04-24 13:58 稀音络合物 阅读(8) 评论(2) 推荐(0) 编辑
摘要: 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 = '-') # 指 阅读全文
posted @ 2022-04-12 15:15 稀音络合物 阅读(26) 评论(3) 推荐(0) 编辑
摘要: 实验任务一 task1_1.py # print输出的几种用法 # 用法1:用于输出单个字符串或单个变量 print('hey, u') # 用法2: 用于输出多个数据项,用逗号分隔 print('hey', ' u') x,y,z = 1,2,3 print(x, y, z) # 用法3: 用户混 阅读全文
posted @ 2022-03-28 09:53 稀音络合物 阅读(27) 评论(4) 推荐(0) 编辑