Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def truncate(number, digits):
- stepper = pow(10.0, digits)
- return math.trunc(stepper*number)/stepper
- n = int(input("Entre com o número n: "))
- aux = 2*10**n
- soma = 0
- for i in range(aux+1):
- termo = (4*(-1)**i)/(2*i+1)
- soma += termo
- ad = truncate(soma, n)
- print("O valor da aproximação é {}".format(ad))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement