Question IV:

Write a program that computes π using the following series expansion.

Write a program that displays the π value for i = 100, 500, 1000 and 10000. Your program should also display the

difference between the approximate π value that you calculated with the series formula and the π value using math

library (use math.pi).

Source: Python Questions

## One Reply to “Write a program that displays the π value for i = 100, 500, 1000 and 10000 [closed]”

Pi = 4(1 – 1/3 + 1/5 – 1/7 + 1/9 – 1/11 +……+ (-1)^i+1/2i-1)

Write a program that displays the π value for i = 100, 500, 1000 and 10000. Your program should also display the

difference between the approximate π value that you calculated with the series formula and the π value using math

library (use math.pi).

You can use a nested loop like:

# Take each value of i.

for i in [100,500,1000, 10000]:

# compute pi number

for j in range(1,i):