摘要: import random import sys from collections import defaultdict class TableTennisGame: """乒乓球比赛模拟类""" def init(self): self.player1 = None self.player2 = 阅读全文
posted @ 2025-06-17 16:37 kk/ 阅读(10) 评论(0) 推荐(0)
摘要: import pygame import random import sys 初始化pygame pygame.init() 屏幕设置 WIDTH, HEIGHT = 800, 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame. 阅读全文
posted @ 2025-06-17 15:36 kk/ 阅读(63) 评论(0) 推荐(0)
摘要: Python语言程序设计学习心得体会 作为一名大一学生,结束了一学期的Python语言程序设计课程学习后,我对编程世界的认知发生了翻天覆地的变化,这段学习经历也成为我大学探索之旅中意义非凡的开端。 初次接触Python,其简洁的语法规则就像一把打开编程大门的钥匙。记得第一次敲下 print("Hel 阅读全文
posted @ 2025-06-17 15:26 kk/ 阅读(104) 评论(0) 推荐(0)
摘要: 8.1 import random def ping_pong_match(): player1_score = 0 player2_score = 0 while True: # 随机决定得分方 winner = random.choice([1, 2]) if winner == 1: play 阅读全文
posted @ 2025-05-24 14:07 kk/ 阅读(21) 评论(0) 推荐(0)
摘要: 7.1 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(c 阅读全文
posted @ 2025-05-19 12:43 kk/ 阅读(25) 评论(0) 推荐(0)
摘要: import turtle import time import datetime COLORS = { 'year': 'red', 'month': 'blue', 'day': 'green', 'hour': 'purple', 'minute': 'orange' } DIGIT_SEGM 阅读全文
posted @ 2025-05-04 15:18 kk/ 阅读(16) 评论(0) 推荐(0)
摘要: import random def genpwd(length): # 生成一个长度为length的数字密码 password = '' for _ in range(length): password += str(random.randint(0, 9)) # 生成0-9的随机数字 return 阅读全文
posted @ 2025-04-26 22:17 kk/ 阅读(33) 评论(0) 推荐(0)
摘要: 书p196程序练习题 5.1 def print_grid(width): plus = '+' dash = ' - ' pipe = '|' space = ' ' horizontal_line = plus + (dash * width + plus) * width + '\n' ver 阅读全文
posted @ 2025-04-20 12:47 kk/ 阅读(20) 评论(0) 推荐(0)
摘要: 4.1 import random def guess_number(): target = random.randint(1, 100) count = 0 while True: guess = int(input("请输入你猜的数字(1-100): ")) count += 1 if gues 阅读全文
posted @ 2025-03-31 22:32 kk/ 阅读(48) 评论(0) 推荐(0)
摘要: 3.19 import time date_str = time.strftime("%Y年%m月%d日",time.localtime()) print("当前日期:",date_str) 3.20 import time current_time = time.localtime() forma 阅读全文
posted @ 2025-03-29 15:20 kk/ 阅读(12) 评论(0) 推荐(0)