摘要: import random import matplotlib.pyplot as plt from collections import defaultdict 乒乓球比赛模拟器 class TableTennisSimulator: def init(self, player_a, player 阅读全文
posted @ 2025-06-23 14:31 邓雁戈 阅读(19) 评论(0) 推荐(0)
摘要: import jieba from collections import Counter import matplotlib.pyplot as plt 1. 读取本地《西游记》文本文件(UTF-8编码) with open("西游记.txt", "r", encoding="utf-8") as 阅读全文
posted @ 2025-06-23 14:26 邓雁戈 阅读(22) 评论(0) 推荐(0)
摘要: Python基础学习心得(适合初学者) 初识Python的感受 Python的语法非常简洁直观,相比其他编程语言(比如C++或Java),代码更接近自然语言,特别适合编程新手。例如: print("Hello, World!") # 一行代码就能输出结果 不需要复杂的结构,就能快速运行程序,这种即时 阅读全文
posted @ 2025-06-23 14:07 邓雁戈 阅读(41) 评论(0) 推荐(0)
摘要: import pygame import random import sys import time 游戏配置 class GameConfig: """游戏配置参数""" # 网格设置 GRID_SIZE = 20 GRID_WIDTH = 30 GRID_HEIGHT = 20 # 窗口大小 W 阅读全文
posted @ 2025-06-22 02:06 邓雁戈 阅读(17) 评论(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 19:37 邓雁戈 阅读(47) 评论(0) 推荐(0)
摘要: 264页作业 作业7.1 import tokenize import keyword from io import BytesIO def convert_python_file(source_path, target_path): with open(source_path, 'rb') as 阅读全文
posted @ 2025-05-18 18:16 邓雁戈 阅读(23) 评论(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 17:38 邓雁戈 阅读(22) 评论(0) 推荐(0)
摘要: 习题4.1 target = 425 guess = 0 F = 1 while guess != target: guess = eval(input("请输入一个猜测的整数(1至1000):")) if guess > target: print("猜大了") F += 1 elif guess 阅读全文
posted @ 2025-04-06 21:01 邓雁戈 阅读(47) 评论(0) 推荐(0)
摘要: 3.19 import time t = time.gmtime() print(time.strftime("%Y-%m-%d",t)) 3.20 import time current_time = time.localtime() format1 = time.strftime("%Y年%m月 阅读全文
posted @ 2025-03-30 18:56 邓雁戈 阅读(14) 评论(0) 推荐(0)
摘要: 3.1 intial_weight = 50 weight_gain = 0.5 moon_weight_ratio = 0.165 print("年份\t地球体重(kg)\t月球体重(kg)") for year in range(1,11): earth_weight = intial_weig 阅读全文
posted @ 2025-03-23 18:07 邓雁戈 阅读(13) 评论(0) 推荐(0)