Pythonで円周率を定数で取得する方法/math.piの使い方

pi IT

mathモジュールにあるpi定数を取得すると、利用可能な範囲の精度で円周率を取得することができます。

スポンサーリンク

math.pi

math組み込みモジュールの一種です。
mathモジュールを使えるようにするには、まず頭でimport mathします。
#python
import math
print(math.pi)
その上でmathモジュールpi定数を取得すれば、
python内で円周率を取得して利用することができます。
Python操作方法、関数・メソッドリファレンス
使用用途別にまとめたPythonリファレンスページです。 初期準備、基本概念 ダウンロード、インストール、起動 ShellとEditor、保存、実行 保存したPythonの起動 コメント、docstring、行またぎ コメント、...

コメント

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny

モバイルバージョンを終了