MENU
Question -

Create a function that computes the approximation of pi, based on the number of iterations specified, pi can be computed by 4*(l-l/3+l/5-l/7+l/9-тАж).



Answer -

def piApprox(num):
i = 1
pi = 0
while i<=num:
#set тАШwhileтАЩ termination condition
pi +=((4/float(2*i-l)n-l)**(i+l))
#compute the ith term of the series
i+=l┬а ┬а # update i
return pi

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×