Answers for "python pi"

2

python pi value

#import pi function from math module
from math import pi

#Show pi value
print(pi)
Posted by: Guest on December-14-2020
17

python floor

import math
x = 3.86356
math.floor(x)
#Returns: 3
math.ceil(x)
#Returns: 4
Posted by: Guest on May-18-2020
3

pi in python math

>>>import math
>>> math.pi
3.141592653589793
Posted by: Guest on October-08-2020
8

python pil

from PIL import Image

img = Image.open("./my_image.png")
Posted by: Guest on July-14-2020
1

pi python

# Approximation of the number PI through the Nilakantha's series

from decimal import *
getcontext().prec = 100

s = Decimal(1);   #Signal for the next operation
pi = Decimal(3);

n = input("Enter the number of iterations: ")         

for i in range (2, n * 2, 2):
    pi += (s*(Decimal(4)/(Decimal(i)*(Decimal(i)+Decimal(1))*(Decimal(i)+Decimal(2)))))
    s *= -1

print ("Aproximated value of PI :")
print (pi)
Posted by: Guest on October-25-2021
0

pi in python

import math #importing the math functions

pi = math.pi #getting the value of pi

print(pi) #printing the result
Posted by: Guest on March-29-2021

Browse Popular Code Answers by Language