摘要: 8.3 from turtle import * def square(size=50, rgb='red'): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800, 600) speed(0) n = 1 阅读全文
posted @ 2022-06-13 16:20 花二 阅读(31) 评论(2) 推荐(0) 编辑
摘要: 7.5.1 ''' 一个类User 数据: 用户名、密码、帐号状态 操作:显示账户信息、修改密码 ''' class User: '''判断密码正误''' def __init__(self,name='guest',password='111111',status='1'): self._name 阅读全文
posted @ 2022-06-06 22:56 花二 阅读(30) 评论(2) 推荐(0) 编辑
摘要: 6.3 def is_valid(x): data=x if len(data)!=18: return False else: if ord(data[-1])==88 or 48<=ord(data[-1])<=57: return True else: return False with op 阅读全文
posted @ 2022-05-22 11:17 花二 阅读(11) 评论(1) 推荐(0) 编辑
摘要: 5.3 with open('5//data3.txt','r')as f: data=f.read().split('\n') del data[0] a=list(map(float,data)) b=[] for i in a: if i-int(i)<=0.4: b.append(int(i 阅读全文
posted @ 2022-05-14 16:25 花二 阅读(20) 评论(2) 推荐(0) 编辑
摘要: 4.1 print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) 不是 line1:内置函数 line3:赋值给予的数 line7:局部变量 阅读全文
posted @ 2022-05-07 16:07 花二 阅读(49) 评论(1) 推荐(0) 编辑
摘要: 3.1 import random print('用列表存储随机整数: ') ls = [random.randint(1, 100) for i in range(5)] print(ls) print('\n用集合存储随机整数: ') s1 = {random.randint(1,100)for 阅读全文
posted @ 2022-04-23 17:10 花二 阅读(38) 评论(1) 推荐(0) 编辑
摘要: 2.1 # 基础操作练习: 列表及列表推导式、格式化、类型转换 x = list(range(10)) print('整数输出1: ', end = '') for i in x: print(i, end=' ') print('\n整数输出2: ', end = '') for i in x: 阅读全文
posted @ 2022-04-10 15:12 花二 阅读(28) 评论(2) 推荐(0) 编辑
摘要: 1. 实验任务1 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-27 19:19 花二 阅读(18) 评论(1) 推荐(0) 编辑