摘要: 1 from turtle import * 2 3 def square(size=50, rgb='yellow'): 4 '''绘制正方形 5 参数size指定边长 6 参数rgb指定画笔颜色 7 如果没有给参数,采用默认值 8 ''' 9 pencolor(rgb) 10 for i in 阅读全文
posted @ 2022-06-14 09:07 yfxyyczs 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 1 class User: 2 def __init__(self,name,password,status): 3 if name=="" and password=="": 4 self.name="guest" 5 self.password="111111" 6 self.status="1 阅读全文
posted @ 2022-06-07 23:13 yfxyyczs 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 3 1 def is_valid(a): 2 l=0 3 f=0 4 for i in a: 5 l+=1 6 if '0'<=i<='9' or i=='X': 7 pass 8 else: 9 f+=1 10 break 11 if l!=18 or f!=0: 12 return False 阅读全文
posted @ 2022-05-25 15:51 yfxyyczs 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 3 1 with open('data3.txt','r',encoding='utf-8') as f1: 2 with open('data3_processed.txt', 'w', encoding='utf-8') as f2: 3 a=f1.read().split('\n') 4 a. 阅读全文
posted @ 2022-05-16 20:39 yfxyyczs 阅读(6) 评论(1) 推荐(0) 编辑
摘要: 1 不是 line1、3、11是全局作用域 line7是函数作用域 2-2 1 list1 = [1, 9, 8, 4] 2 3 print( sorted(list1) ) 4 print( sorted(list1, reverse=True) ) 5 print( sorted(list1, 阅读全文
posted @ 2022-05-10 09:27 yfxyyczs 阅读(4) 评论(1) 推荐(0) 编辑
摘要: task1 1 import random 2 print('用列表存储随机整数: ') 3 ls = [random.randint(1, 100) for i in range(5)] 4 print(ls) 5 print('\n用集合存储随机整数: ') 6 s1 = {random.ran 阅读全文
posted @ 2022-04-26 16:41 yfxyyczs 阅读(7) 评论(1) 推荐(0) 编辑
摘要: task 1 1 #1 2 x = list(range(10)) 3 4 print('整数输出1: ', end = '') 5 for i in x: 6 print(i, end=' ') 7 8 print('\n整数输出2: ', end = '') 9 for i in x: 10 p 阅读全文
posted @ 2022-04-10 11:39 yfxyyczs 阅读(9) 评论(2) 推荐(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 = {}'.forma 阅读全文
posted @ 2022-03-24 11:49 yfxyyczs 阅读(15) 评论(2) 推荐(0) 编辑