摘要: import random class BadmintonMatch: def init(self, player1_ability, player2_ability): self.player1_ability = player1_ability self.player2_ability = pl 阅读全文
posted @ 2025-06-23 02:16 城阳 阅读(1) 评论(0) 推荐(0)
摘要: import pygame import random import sys 初始化pygame 3019 pygame.init() 屏幕设置 SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 screen = pygame.display.set_mode((SCRE 阅读全文
posted @ 2025-06-23 01:54 城阳 阅读(3) 评论(0) 推荐(0)
摘要: NumPy、SciPy、Pandas和Matplotlib的读书报告 一、NumPy基础与应用 基本函数用法 NumPy是Python中用于科学计算的基础库,提供了高性能的多维数组对象和工具。 import numpy as np 创建数组 arr1 = np.array([1, 2, 3, 4, 阅读全文
posted @ 2025-06-23 01:49 城阳 阅读(2) 评论(0) 推荐(0)
摘要: import jieba import re from collections import Counter import chardet 1. 安全读取文件(自动处理编码和路径) def read_file_safely(path): try: # 检测文件编码 with open(path, ' 阅读全文
posted @ 2025-06-23 01:17 城阳 阅读(2) 评论(0) 推荐(0)
摘要: import pygame import random import sys 初始化 pygame.init() 颜色定义 WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) GREEN = (0, 255, 0) DARK_GRE 阅读全文
posted @ 2025-06-22 02:52 城阳 阅读(3) 评论(0) 推荐(0)
摘要: 一、Python语言特点与学习价值 Python作为一门高级编程语言,以其独特的魅力吸引着全球开发者。在初学阶段,我就被它简洁优雅的语法所折服。相比其他语言,Python代码更接近自然语言,通过简单的缩进来表示代码块,避免了繁琐的大括号,使代码结构一目了然。这种设计哲学体现了Python"可读性至上 阅读全文
posted @ 2025-06-22 02:49 城阳 阅读(2) 评论(0) 推荐(0)
摘要: import random def printIntro(): print("这个程序模拟两个选手A和B的乒乓球竞技比赛") print("程序运行需要A和B的能力值(以0到1之间的小数表示)") def getInputs(): a = float(input("请输入选手A的能力值(0-1): 阅读全文
posted @ 2025-05-25 20:32 城阳 阅读(19) 评论(0) 推荐(0)
摘要: def rewrite_py_file(file_path): try: with open(file_path, 'r', encoding='utf - 8') as f: content = f.read() new_content = "" i = 0 while i < len(conte 阅读全文
posted @ 2025-05-18 18:25 城阳 阅读(16) 评论(0) 推荐(0)
摘要: def drawsquare(num): a=int(num**0.5) for i in range(a): print(a"+ "+"+") for j in range(3): print(a"| "+"|") print(a"+ "+"+") n=eval(input("请输入正整数:")) 阅读全文
posted @ 2025-04-20 20:44 城阳 阅读(15) 评论(0) 推荐(0)
摘要: import decimal from decimal import Decimal import time def calculate_pi(iterations, progress_callback=None): # 设置足够的计算精度(根据迭代次数调整) decimal.getcontext( 阅读全文
posted @ 2025-04-13 20:07 城阳 阅读(25) 评论(0) 推荐(0)