python计算:pi/4=1-1/3+1/5-1/7+…
2024-10-20 09:36:57
当有一项的绝对值小于10e-6停止计算
def cul() :
ans = 0;add = 1
sign = 1
while(1/add>10**(-6)) :
ans = ans + sign/add
add = add + 2
sign = -sign
else :
ans += sign/add
print("pi = {}".format(ans * 4))
print("pi = %.8f"%(ans * 4)) cul()
最新文章
- SQL 2012 镜像 图解(解决1418)
- install zabbix-agent on CENTOS
- Spring Boot 配置优先级顺序
- docker的一些命令
- linux常用服务软件搭建及使用技巧
- hive中UDF、UDAF和UDTF使用
- Visual Studio 2015 NuGet Update-Package 失败/报错:Update-Package : Unable to load the service index for source https://api.nuget.org/v3/index.json.
- python做数据驱动
- java中String字符串的==解析
- Shader、Draw Call和渲染管线(Rendering Pipeline)
- ProcessExplorer使用分享
- Conjugate Function
- VC++ 获取系统时间、程序运行时间(精确到秒,毫秒)的五种方法
- linux查看目录下所有文件内容中是否包含某个字符串
- Jmeter常用脚本开发之Debug Sampler
- php Only variables can be passed by reference
- sql 智能提示
- vue 登录验证引擎
- IDEA里运行程序时出现Error:scalac:error while loading JUnit4 , Scala signature JUnit4 has wrong version错误的解决办法(图文详解)
- House of Roman 实战