摘要: 实验任务一 实验源码 class Account: '''一个模拟银行账户的简单类''' def __init__(self, name, account_number, initial_amount = 10): '''构造新账户''' self._name = name self._card_n 阅读全文
posted @ 2023-06-07 17:34 赖鑫 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 试验任务一 实验源码 task1 from turtle import * def move(x, y): '''画笔移动到坐标(x,y)处''' penup() goto(x, y) pendown() def draw(n, size = 100): '''绘制边长为size的正n变形''' f 阅读全文
posted @ 2023-06-07 17:31 赖鑫 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 实验任务一 task1-1 实验源码 ''' 统计文件data1.txt行数(不包括空白行) data1.txt中的空白行包括由空格、Tab键(\t)、换行(\n)构成的空白行 ''' with open('data1.txt', 'r', encoding = 'utf-8') as f: dat 阅读全文
posted @ 2023-06-04 10:37 赖鑫 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 实验任务1 task1-1 实验源码 print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) 实验截图 问题:task1.py源码中,共有4 阅读全文
posted @ 2023-05-22 13:28 赖鑫 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 实验任务一: 实验源码: import random print('用列表存储随机整数: ') lst = [random.randint(0, 100) for i in range(5)] print(lst) print('\n用集合存储随机整数: ') s1 = {random.randin 阅读全文
posted @ 2023-04-23 12:17 赖鑫 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 实验二 字符串和列表 实验任务1 task1.py 实验源码 x = 'nba FIFA' print(x.upper()) print(x.lower()) print(x.swapcase()) print() x = 'abc' print(x.center(10,'*')) print(x. 阅读全文
posted @ 2023-03-25 11:26 赖鑫 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 实验任务1 task1_1 实验源码 1 print('hey,u') 2 3 print('hey','u') 4 5 x,y,z=1,2,3 6 print(x,y,z) 7 8 print('x=%d,y=%d,z=%d'%(x,y,z)) 9 print('x={},y={},z={}'.f 阅读全文
posted @ 2023-03-14 14:03 赖鑫 阅读(14) 评论(0) 推荐(0) 编辑