摘要:
def calculate_and_print(num, calculator, formatter): result = calculator(num) formatter(num, result)def print_with_vertical_bar(num, result): print(f" 阅读全文
posted @ 2025-10-31 21:33
偷懒的阿贤
阅读(3)
评论(0)
推荐(0)
摘要:
#导入测试内置模块import unittest#导入要测试的api,Student为类名from _oop import Studentfrom _oop import SmallStudent#需要继承unittest.TestCase,def函数必须用test_开头class MyTestCa 阅读全文
posted @ 2025-10-31 21:02
偷懒的阿贤
阅读(4)
评论(0)
推荐(0)
摘要:
#导入测试内置模块import unittest#导入要测试的apifrom _try_except import condition#需要继承unittest.TestCase,def函数必须用test_开头class MyTestCase(unittest.TestCase): def test 阅读全文
posted @ 2025-10-31 20:36
偷懒的阿贤
阅读(5)
评论(0)
推荐(0)
摘要:
try: user_weight = float(input("请输入您的体重(单位:kg):")) user_height = float(input("请输入您的身高(单位:m):")) user_BMI = user_weight / (user_height ** 2)except Valu 阅读全文
posted @ 2025-10-31 20:20
偷懒的阿贤
阅读(6)
评论(0)
推荐(0)
摘要:
#在一个新的名字为“poem.txt”的文件里,写入以下内容:#我欲乘风归去#又恐琼楼玉宇with open("./poem.txt", "w", encoding="utf-8") as f: f.write("我欲乘风归去,\n又恐琼楼玉宇.\n")#任务2:在上面的poem.txt中文件结尾处 阅读全文
posted @ 2025-10-31 17:58
偷懒的阿贤
阅读(2)
评论(0)
推荐(0)
摘要:
#方法一:读取文件f = open("./_math.py", "r", encoding="utf-8")content = f.readlines()for line in content: print(line)f.close()#方法二:读取文件,不用close()with open("./ 阅读全文
posted @ 2025-10-31 17:57
偷懒的阿贤
阅读(3)
评论(0)
推荐(0)
摘要:
复制绝对路径 阅读全文
posted @ 2025-10-31 17:44
偷懒的阿贤
阅读(3)
评论(0)
推荐(0)
摘要:
class Employee: def __init__(self, name, id): self.name = name self.id = id def print_info(self): print(f"员工名字:{self.name},工号:{self.id}")class FullTim 阅读全文
posted @ 2025-10-31 17:25
偷懒的阿贤
阅读(3)
评论(0)
推荐(0)
摘要:
class Student: def __init__(self, name, student_id): self.name = name self.student_id = student_id self.grades = {"语文": 0, "数学":0, "英语": 0} def set_gr 阅读全文
posted @ 2025-10-31 16:50
偷懒的阿贤
阅读(5)
评论(0)
推荐(0)
摘要:
class CuteCat: def __init__(self, cat_name, cat_age, _cat_color): self.name = cat_name self.age = cat_age self.color = _cat_colorcat1 = CuteCat("Jojo" 阅读全文
posted @ 2025-10-31 16:13
偷懒的阿贤
阅读(3)
评论(0)
推荐(0)
摘要:
class Student: def __init__(self, study_name: int, school_name: str): self.name = study_name self.school_name = school_name def go_school(self, school 阅读全文
posted @ 2025-10-31 11:54
偷懒的阿贤
阅读(1)
评论(0)
推荐(0)
摘要:
一、项目结构与命名 my_utils/├── src/│ └── my_utils/ # 真正的包目录(Python 3.3+ 可省略 __init__.py,但建议保留)│ ├── __init__.py│ └── calculator.py├── tests/│ └── test_calcul 阅读全文
posted @ 2025-10-31 11:53
偷懒的阿贤
阅读(8)
评论(0)
推荐(0)
摘要:
#使用import引入模块import statisticsprint("\n" + str(statistics.median([1,2,3,4,5,6,7,8,9])))#使用from xx import xx 直接引入模块中的函数from statistics import meanprint 阅读全文
posted @ 2025-10-31 11:46
偷懒的阿贤
阅读(2)
评论(0)
推荐(0)
摘要:
def calculate_BMI(weight, height): BMI = weight / (height * height) if BMI < 18.5: category = "偏瘦" elif BMI < 25: category = "正常" elif BMI < 30: categ 阅读全文
posted @ 2025-10-31 11:29
偷懒的阿贤
阅读(1)
评论(0)
推荐(0)
摘要:
def calculate_sector(central_angle, radius): #接下来是一些定义函数的代码 sector_area = central_angle / 360 * 3.14 * radius ** 2 print("Sector area: ", sector_area) 阅读全文
posted @ 2025-10-31 11:17
偷懒的阿贤
阅读(2)
评论(0)
推荐(0)
摘要:
1 阅读全文
posted @ 2025-10-31 10:33
偷懒的阿贤
阅读(5)
评论(0)
推荐(0)
摘要:
1 阅读全文
posted @ 2025-10-31 10:32
偷懒的阿贤
阅读(4)
评论(0)
推荐(0)
摘要:
1 阅读全文
posted @ 2025-10-31 10:32
偷懒的阿贤
阅读(2)
评论(0)
推荐(0)
摘要:
gpa_dict = {}#字典增加key:valuegpa_dict.setdefault("A", 10.2)gpa_dict.setdefault("B", 30.315)gpa_dict.setdefault("C", 20.45)gpa_dict.setdefault("D", 40.65 阅读全文
posted @ 2025-10-31 10:31
偷懒的阿贤
阅读(5)
评论(0)
推荐(0)
浙公网安备 33010602011771号