摘要: 8.1 from random import random def printIntro(): print("这个程序模拟乒乓球比赛,分析体育竞技规律。") print("程序运行需要输入两个选手的能力值(0 - 1之间的小数)和模拟比赛的场次。") def getInputs(): a = eva 阅读全文
posted @ 2025-05-25 15:28 piuky 阅读(59) 评论(0) 推荐(0)
摘要: 7.1 def convert_to_uppercase(): file_path = input("请输入python源文件路径:") try: with open(file_path,'r',encoding='utf-8') as f: content = f.read() new_conte 阅读全文
posted @ 2025-05-18 15:15 piuky 阅读(60) 评论(0) 推荐(0)
摘要: from random import random,seed from time import perf_counter seed(123) DARTS = 1000 * 1000 hits = 0.0 start = perf_counter() for i in range(1, DARTS + 阅读全文
posted @ 2025-04-26 22:06 piuky 阅读(16) 评论(0) 推荐(0)
摘要: 5.1 def draw_grid(width): horizontal_line = '+' + ' +' * width vertical_line = '|' + ' |' * width for i in range(width): print(horizontal_line) for i 阅读全文
posted @ 2025-04-20 17:37 piuky 阅读(10) 评论(0) 推荐(0)
摘要: 4.1 target = 425 guess = 0 count = 0 while guess != target: guess = eval(input("请输入一个整数(1至1000)😊) count += 1 if guess > target: print("猜大了") elif gue 阅读全文
posted @ 2025-04-05 22:59 piuky 阅读(11) 评论(0) 推荐(0)
摘要: 3.6 import time a = "strating" print("{:^}".format(a),end='') for i in range(11): s = '.' * i print("{:<}".format(s),end='') time.sleep(1) print("Done 阅读全文
posted @ 2025-03-29 20:20 piuky 阅读(12) 评论(0) 推荐(0)
摘要: 3.1 initial_weight = 50 print("年份\t地球体重(kg)\t月球体重(kg)") for year in range(1, 11): earth_weight = initial_weight + (year - 1) * 0.5 moon_weight = earth 阅读全文
posted @ 2025-03-23 16:25 piuky 阅读(8) 评论(0) 推荐(0)
摘要: 蟒蛇绘制 import turtle turtle.setup(650,360,600,200) turtle.penup() turtle.fd(-250) turtle.pendown() turtle.pensize(25) turtle.pencolor("pink") turtle.set 阅读全文
posted @ 2025-03-15 16:09 piuky 阅读(21) 评论(0) 推荐(0)
摘要: 由于一至三题只存了源代码,自己写的没有保存,所以仅以截图展示。四至八题则采取代码和截图一起的方式展示。 2.4 import turtle turtle.setup(650,360,800,200) turtle.penup() turtle.fd(-250) turtle.pendown() tu 阅读全文
posted @ 2025-03-15 15:54 piuky 阅读(24) 评论(0) 推荐(0)
摘要: import turtle 设置画布和画笔 screen = turtle.Screen() screen.setup(width=800, height=600) pen = turtle.Turtle() pen.speed(0) pen.hideturtle() 绘制红色背景 pen.penu 阅读全文
posted @ 2025-03-02 22:05 piuky 阅读(35) 评论(0) 推荐(0)