摘要: 实验任务3 from turtle import * def square(size=50, rgb='gold'): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800, 600) speed(0) n 阅读全文
posted @ 2022-06-08 16:56 杖卫 阅读(18) 评论(1) 推荐(0) 编辑
摘要: class User: """用户""" count = 0 def __init__(self, name='guest', password=111111, status=1): User.count += 1 self.name = name self.password = password 阅读全文
posted @ 2022-06-01 16:20 杖卫 阅读(43) 评论(1) 推荐(0) 编辑
摘要: 实验任务3 def is_valid(a): """判断身份证是否合法""" if len(a) != 18: return False else: if a[-1] == "Y": return False else: return True with open("data3_id.txt",en 阅读全文
posted @ 2022-05-18 16:55 杖卫 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 实验任务3 def round_1(a): """四舍五入""" b = a // 1 c = a * 10 - b * 10 if c < 5: return b else: return b + 1 with open("data3.txt", "r", encoding="utf-8") as 阅读全文
posted @ 2022-05-10 23:35 杖卫 阅读(33) 评论(2) 推荐(0) 编辑
摘要: 实验任务一 print(sum) sum = 42 print(sum) def inc(n): sum = n + 1 print(sum) return sum sum = inc(7) + inc(7) print(sum) 1.Built-in 2.Global 3.Local 4.Glob 阅读全文
posted @ 2022-05-04 22:36 杖卫 阅读(37) 评论(1) 推荐(0) 编辑
摘要: 实验任务1 import random print('用列表存储随机整数: ') ls = [random.randint(1, 100) for i in range(5)] print(ls) print('\n用集合存储随机整数: ') s1 = {random.randint(1,100) 阅读全文
posted @ 2022-04-20 19:04 杖卫 阅读(25) 评论(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-10 21:02 杖卫 阅读(15) 评论(2) 推荐(0) 编辑
摘要: 实验任务1 # print输出的几种用法 # 用法1:用于输出单个字符串或单个变量 print('hey, u') # 用法2: 用于输出多个数据项,用逗号分隔 print('hey', ' u') x,y,z = 1,2,3 print(x, y, z) # 用法3: 用户混合字符串和变量值 pr 阅读全文
posted @ 2022-03-23 18:45 杖卫 阅读(36) 评论(3) 推荐(0) 编辑