没有合适的资源?快使用搜索试试~ 我知道了~
部分展示: import matplotlib.pyplot as plt import numpy as np from decimal import Decimal from decimal import getcontext import time def heartfunc(x, y): return (x ** 2 + y ** 2 - 1) ** 3 - x ** 2 * y ** 3 <= 0 def cal_pi(precision): getcontext().prec = precision return sum(1 / Decimal(16) ** k * (Decimal(4) / (8 * k + 1) - Decimal(2) / (8 * k + 4) - Decimal(1) / (8 * k + 5) -
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![](https://csdnimg.cn/release/download_crawler_static/89324138/bg1.jpg)
代码:
import matplotlib.pyplot as plt
import numpy as np
from decimal import Decimal
from decimal import getcontext
import time
def heartfunc(x, y):
return (x ** 2 + y ** 2 - 1) ** 3 - x ** 2 * y ** 3 <= 0
def cal_pi(precision):
getcontext().prec = precision
return sum(1 / Decimal(16) ** k *
(Decimal(4) / (8 * k + 1) -
Decimal(2) / (8 * k + 4) -
Decimal(1) / (8 * k + 5) -
Decimal(1) / (8 * k + 6)) for k in range(precision))
def printer(text, delay=0.1314):
for ch in text:
print(ch, end='', flush=True)
time.sleep(delay)
if __name__ == '__main__':
n = 1314
x = np.linspace(-2, 2, n)
y = np.linspace(-2, 2, n)
X, Y = np.meshgrid(x, y)
plt.contourf(X, Y, heartfunc(X, Y), cmap=plt.cm.autumn)
# Colour Query https://matplattlib.org/examples/color/collormaps_reference.html
plt.title("5201314")
plt.show()
loveInPi = str(cal_pi(1314))
heart = ['5', '2', '0', '1', '3', '1', '4']
iloveyou = "5201314"
love = ""
i, j = 0, 0
while love != iloveyou:
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/694daa3f15294661b60231a3beddc4fb_yykyyk2010.jpg!1)
c++惊鸿
- 粉丝: 213
- 资源: 2
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)