摘要: 实验任务1 class Account: '''一个模拟银行账户的简单类''' def __init__(self, name, account_number, initial_amount = 10): '''构造新账户''' self._name = name self._card_no = a 阅读全文
posted @ 2023-06-07 18:38 咖啡店的茅羽耶 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 实验任务1 task1_1 from turtle import * def moveto(x,y): ''' 画笔移动到坐标(x,y)处 ''' penup() goto(x,y) pendown() def draw(n,size = 100): ''' 绘制边长为size的正n边形 ''' f 阅读全文
posted @ 2023-06-05 22:17 咖啡店的茅羽耶 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 实验任务6 task6 # 读取并处理原始数据with open('data6.csv','r',encoding = 'gbk') as f: old_data = f.read().split('\n') del old_data[0] # 四舍五入得到新数据 new_data = [] for 阅读全文
posted @ 2023-06-03 14:18 咖啡店的茅羽耶 阅读(51) 评论(1) 推荐(0) 编辑
摘要: 1.实验任务1 1 print(sum) 2 sum = 42 3 print(sum) 4 5 def inc(n): 6 sum = n + 1 7 print(sum) 8 return sum 9 10 sum = inc(7) + inc(7) 11 print(sum) 问题:不是。li 阅读全文
posted @ 2023-05-20 20:34 咖啡店的茅羽耶 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 1.试验任务1 1 import random 2 3 print('用列表存储随机整数:') 4 lst = [random.randint(0,100) for i in range(5)] 5 print(lst) 6 7 print('\n拥集合存储随机整数:') 8 s1 = {rando 阅读全文
posted @ 2023-04-22 10:07 咖啡店的茅羽耶 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 1.试验任务1 1 x = 'nba FIFA' 2 print(x.upper()) # 字符串转大写 3 print(x.lower()) # 字符串转小写 4 print(x.swapcase()) # 字符串大小写互换 5 print() 6 x = 'abc' 7 print(x.cent 阅读全文
posted @ 2023-03-27 19:00 咖啡店的茅羽耶 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 实验结论: 实验任务1:print()的不同用法及丰富的格式控制方式 task1_1 使用三种方式实现数据的默认输出 1 # 用法1:用于输出单个字符串或单个变量 2 print('hey,u') 3 4 # 用法2:用于输出多个数据项,用逗号分割 5 print('hey','u') 6 x,y, 阅读全文
posted @ 2023-03-07 23:15 咖啡店的茅羽耶 阅读(74) 评论(1) 推荐(0) 编辑