please help.....

Python/PHP/Perl 开发与设计
回复
asqew
帖子: 25
注册时间: 2007-10-05 19:04
送出感谢: 0
接收感谢: 0

please help.....

#1

帖子 asqew » 2008-01-26 23:32

I am writing a program using Python to calc PI as a training

c = 0
x = raw_input('inputX')
y=int(x)
for i in range(1,y):
a=1.0000/i**4
b=a+c
c=b
print b
print (b*90)**0.25

But it just out put 3.14159232727 When i input x As 91
But i want it output more number after 小數點,What can i do??
i don 't know how to type in chinese,sorry
xyz042
帖子: 31
注册时间: 2006-10-18 18:03
送出感谢: 0
接收感谢: 0

#2

帖子 xyz042 » 2008-01-30 17:04

代码: 全选

c = 0
x = raw_input('inputX') 
y=int(x) 
for i in range(1,y): 
    a=1.0000/i**4 
    b=a+c 
    c=b 
print '%1.20f'%b 
print '%1.20f'%(b*90)**0.25
我也刚刚开始学习python,不知道你要不是不是这种效果。输出:
inputX91
1.08232278402810980000
3.14159232727296980000
其中%1.20f表示:整数位1位,小数点20位的浮点格式。这和C/C++差不多但中间没有用‘,’隔开。

在一行里多个参数。

代码: 全选

print '%1.20f/%1.20f' %(b,(b*90)**0.25)
inputX91
1.08232278402810980000/3.14159232727296980000
asqew
帖子: 25
注册时间: 2007-10-05 19:04
送出感谢: 0
接收感谢: 0

#3

帖子 asqew » 2008-01-30 22:08

great thanks!! :D :D
回复

回到 “Python/Php/Perl”