摘要: 实验1 task1.py 实验源码: 1 class Account: 2 '''一个模拟银行账户的简单类''' 3 def __init__(self, name, account_number, initial_amount = 10): 4 '''构造新账户''' 5 self._name = 阅读全文
posted @ 2023-06-12 17:17 showdownx 阅读(35) 评论(0) 推荐(0)
摘要: 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-06 17:12 showdownx 阅读(21) 评论(0) 推荐(0)
摘要: task1 实验源码: print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) 实验结果: 问题回答:不是。line1中是Python的内置 阅读全文
posted @ 2023-05-22 19:14 showdownx 阅读(28) 评论(0) 推荐(0)
摘要: task1 实验源码: import random print('用列表存储随机整数: ') lst = [random.randint(0, 100) for i in range(5)] print(lst) print('\n用集合存储随机整数: ') s1 = {random.randint 阅读全文
posted @ 2023-04-25 13:13 showdownx 阅读(19) 评论(0) 推荐(0)
摘要: 实验任务1:task1.py: 1 print(x.upper()) 2 print(x.lower()) 3 print(x.swapcase()) 4 print() 5 6 x = 'abc' 7 print(x.center(10, '*')) 8 print(x.ljust(10, '*' 阅读全文
posted @ 2023-03-28 00:38 showdownx 阅读(16) 评论(0) 推荐(0)
摘要: 实验目的: 实验任务1:task1-1 1 # print输出的几种用法 2 3 # 用法1:用于输出单个字符串或单个变量 4 5 print('hey,u') 6 7 8 # 用法2: 用于输出多个数据项,用逗号分隔 9 print('hey', ' u') 10 x,y,z = 1,2,3 11 阅读全文
posted @ 2023-03-09 13:55 showdownx 阅读(31) 评论(1) 推荐(0)