2023年12月28日

小球游戏

摘要: 代码如下: import sys import pygamepygame.init()size = width, height = 1000, 700screen = pygame.display.set_mode(size)color = (0, 0, 0)ball = pygame.image. 阅读全文

posted @ 2023-12-28 23:22 20岁极品少萝 阅读(34) 评论(0) 推荐(0)

2023年12月13日

爬虫单元作业

摘要: (1): import requests url="https://www.baidu.com/" def gethtml(url): try: r=requests.get(url) r.raise_for_status() r.encoding="utf-8" print("text内容:",r 阅读全文

posted @ 2023-12-13 17:58 20岁极品少萝 阅读(56) 评论(0) 推荐(0)

2023年11月21日

七段数码管绘制

摘要: import turtle,datetimedef drawLine(draw): turtle.pendown() if draw else turtle.penup() turtle.fd(40) turtle.right(90)def drawDigit(d): drawLine(True) 阅读全文

posted @ 2023-11-21 22:19 20岁极品少萝 阅读(28) 评论(0) 推荐(0)

2023年11月1日

第二单元作业

摘要: 计算商品金额 money_all=56.75+72.91+88.5+26.37+68.51 #301 money_all_str=str(money_all)print("商品总金额:"+money_all_str)money_real=int(money_all)money_real_str=st 阅读全文

posted @ 2023-11-01 12:18 20岁极品少萝 阅读(85) 评论(0) 推荐(0)

Π的计算

摘要: pi = 0f = 1for k in range (0, 1000): t = 1/(2*k + 1) pi = pi + f*t f = -fprint("圆周率pi = ", 4*pi)import randomdef monte_carlo_pi(n): conut = 0 for i in 阅读全文

posted @ 2023-11-01 12:11 20岁极品少萝 阅读(87) 评论(0) 推荐(0)

2023年10月30日

Π的计算

摘要: import randompi = 0n = 1000000m = 0for i in range(n): x,y = random.random(),random.random() dist = pow(x ** 2+y**2, 0.5) if dist <= 1.0: m+=1pi=4*(m/n 阅读全文

posted @ 2023-10-30 21:33 20岁极品少萝 阅读(44) 评论(0) 推荐(0)

导航