04 2025 档案

摘要:点击查看代码 import random import time from tqdm import tqdm def calculate_pi(num_samples): """ 使用蒙特卡洛方法计算π。 :param num_samples: 样本数量,即模拟的点数。 :return: 计算得到的 阅读全文
posted @ 2025-04-27 20:26 佘婷婷 阅读(14) 评论(0) 推荐(0)
摘要:5.1字符田字格绘制 点击查看代码 def print_grid(width): # 打印上边界 print("+" + "-" * (width * 2 - 1) + "+") # 打印中间的横线 for _ in range(width - 1): print("|" + " " * (widt 阅读全文
posted @ 2025-04-20 18:53 佘婷婷 阅读(25) 评论(0) 推荐(0)
摘要:4.1猜数字游戏的扩展 点击查看代码 #GuessANumMore.py target = 425 guess = 0 n = 0 while guess != target: guess = eval(input("请输入一个猜测的整数(1至1000):")) n += 1 if guess != 阅读全文
posted @ 2025-04-07 20:21 佘婷婷 阅读(37) 评论(0) 推荐(0)