2022年6月12日

8

摘要: from turtle import * def square(size=50, rgb='orange'): '''绘制正方形 参数size指定边长 参数rgb指定画笔颜色 如果没有给参数,采用默认值''' pencolor(rgb) for i in range(4): fd(size) lef 阅读全文

posted @ 2022-06-12 17:30 忆路凉心 阅读(39) 评论(1) 推荐(0) 编辑

2022年6月5日

7

摘要: class User: count = 0 def __init__(m, name = 'guest', password = '111111', zt = '1'): User.count += 1 m.name = name m.password = password m.zt = zt de 阅读全文

posted @ 2022-06-05 13:21 忆路凉心 阅读(106) 评论(1) 推荐(0) 编辑

2022年5月24日

666

摘要: def is_vaild(x): ture_list = ['0','1','2','3','4','5','6','7','8','9','X',] num = 0 for id in x: num+=ture_list.count(id) if num!=18: return False ret 阅读全文

posted @ 2022-05-24 21:31 忆路凉心 阅读(386) 评论(1) 推荐(0) 编辑

2022年5月15日

5

摘要: with open('data5.txt', 'r', encoding='utf-8') as f: data = f.read() line_num = len(data.splitlines()) word_num = len(data.split()) space_num = data.co 阅读全文

posted @ 2022-05-15 12:21 忆路凉心 阅读(52) 评论(1) 推荐(0) 编辑

2022年5月7日

实验四

摘要: task1 print(sum)sum = 42print(sum)def inc(n): sum = n+1 print(sum) return sumsum = inc(7) + inc(7)print(sum) task2 1.内置函数 2.给sum赋予一个值 3.局部变量 4.全局变量 de 阅读全文

posted @ 2022-05-07 13:57 忆路凉心 阅读(33) 评论(2) 推荐(0) 编辑

2022年4月20日

实验三

摘要: task1 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:09 忆路凉心 阅读(35) 评论(3) 推荐(0) 编辑

2022年4月6日

实验2 字符串和列表

摘要: 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 = '-') pri 阅读全文

posted @ 2022-04-06 21:38 忆路凉心 阅读(31) 评论(3) 推荐(0) 编辑

2022年3月23日

实验1 Python开发环境使用和编程初体验

摘要: task1_1.py task1_2.py # 使用字符串的format()方法,对输出数据项进行格式化 x1, y1 = 1.2, 3.57 x2, y2 = 2.26, 8.7 # 输出1 print('{:-^40}'.format('输出1')) # {:-^40}控制输出数据格式: 宽度占 阅读全文

posted @ 2022-03-23 18:16 忆路凉心 阅读(34) 评论(2) 推荐(0) 编辑

导航