摘要: import pygame import sys import random # 素材参考地址:https://www.aigei.com/s?q=flappy+bird&type=2d class Bird(object): """定义一个鸟类""" def __init__(self): """ 阅读全文
posted @ 2023-12-20 08:56 陆宇柒 阅读(36) 评论(0) 推荐(0)
摘要: Numpy: 基础的数学计算模块,来存储和处理大型矩阵,比Python自身的嵌套列表(nested list structure)结构要高效的多,本身是由C语言开发。这个是很基础的扩展,其余的扩展都是以此为基础。数据结构为ndarray,一般有三种方式来创建。 Scipy: 方便、易于使用、专为科学 阅读全文
posted @ 2023-12-20 08:52 陆宇柒 阅读(7) 评论(0) 推荐(0)
摘要: print("乒乓球比赛,学号21") from random import random def printInfo(): print('这个程序模拟两个选手A和B的某种竞技比赛') print('程序运行需要A和B的能力值(以0到1之间的小数表示)') def getInputs(): a = 阅读全文
posted @ 2023-12-20 08:49 陆宇柒 阅读(9) 评论(0) 推荐(0)
摘要: import jieba txt = open("西游记.txt", "r", encoding='utf-8').read() words = jieba.lcut(txt) # 使用精确模式对文本进行分词 counts = {} # 通过键值对的形式存储词语及其出现的次数 for word in 阅读全文
posted @ 2023-12-20 08:46 陆宇柒 阅读(11) 评论(0) 推荐(0)
摘要: import turtle, datetimedef drawGap(): turtle.penup() turtle.fd(5)def drawLine(draw): drawGap() turtle.pendown() if draw else turtle.penup() turtle.fd( 阅读全文
posted @ 2023-11-21 08:26 陆宇柒 阅读(14) 评论(0) 推荐(0)
摘要: #03超市抹零结账行为print('学号:3121')print("\n03")n=eval(input('应付:'))print('实付:',int(n)) #04计算学生成绩的分差和平均分print("\n04")print('学号:3121')A=eval(input('学生A的成绩:'))B 阅读全文
posted @ 2023-10-31 21:28 陆宇柒 阅读(11) 评论(0) 推荐(0)
摘要: 蒙特卡洛法计算π: 通过获得面积比Sy/Sz:让计算机产生很多的随机点(x,y),其中x、y都是[0,1]之间的随机数,可以用判断 是否小于1的方法来确定是否在圆内,则圆内的点数代表圆面积,总点数代表总面积,两者相除就是面积比Sy/Sz。 Python代码展示如下: from random impo 阅读全文
posted @ 2023-10-30 19:50 陆宇柒 阅读(24) 评论(0) 推荐(0)