+ 1

How to print pi(3.1415.......)? Python

Pi can print?

21st Feb 2022, 1:09 PM
Chris
3 Respostas
+ 7
from math import pi print(pi)
21st Feb 2022, 1:11 PM
Lisa
Lisa - avatar
+ 2
print (22/7)
21st Feb 2022, 2:11 PM
A͢J
A͢J - avatar
+ 2
# more practical (Python 3.8>) pi_gen = lambda pre: [[D:=__import__('decimal').Decimal,setattr(__import__('decimal').getcontext(),'prec',600)],[p:=D(3).sqrt()*sum(D(2-k%2*4)/3**k/(2*k+1)for k in range(1100)),print(str(p)[:pre+2])]]and None pi_gen(int(input()))
21st Feb 2022, 10:51 PM
Ervis Meta
Ervis Meta - avatar