Results of 1 - 9 of about 9 for factorial (0.009 sec.)
- doctest --- 対話型の Python の例をテストする 12348
- doctest --- 対話型の Python の例をテストする ソースコード: Lib/doctest.py doctest モジュールは Python の対話セッションに見えるテキストを探し、そのセッションを実行して記載どおりに動作するか検証します。 主な使い方は次のとおりです。 モジュール
...ドキュメント」にもなります。 以下に完全かつ短い実行例を示します: """ これは "example" モジュールです。 example モジュールは factorial() という関数を一つ提供します。 例えば、 >>> factorial(5) 120 """ def factorial ( n ): """0 以上の整数 n の階乗を返します。...>>> [factorial(n) for n in range(6)] [1, 1, 2, 6, 24, 120] >>> factorial(30) 265252859812191058636308480000000 >>> factorial(-1) Tracebac...ll last): ... ValueError: n must be >= 0 浮動小数点数でも階乗を求められますが、その値は厳密に整数でなければなりません: >>> factorial(30.1) Traceback (most recent call last): ... ValueError: n must be exact integer >>> factorial(30.0) 265252859812191058636... - https://man.mtool.work/python/3.14/library/doctest.html
- コルーチンとタスク 11719
- コルーチンとタスク この節では、コルーチンと Task を利用する高レベルの asyncio の API の概略を解説します。 コルーチン ソースコード: Lib/asyncio/coroutines.py async/await 構文で宣言された コルーチン は、 asyncio を使ったアプリケーションを書く
...ール済みの残りのタスクをキャンセルしますが、 gather はキャンセルしません。 以下はプログラム例です: import asyncio async def factorial ( name , number ): f = 1 for i in range ( 2 , number + 1 ): print ( f "Task { name } : Compute factorial( { number } ), cu...rrently i= { i } ..." ) await asyncio . sleep ( 1 ) f *= i print ( f "Task { name } : factorial( { number } ) = { f } " ) return f async def main (): # 3 つの呼び出しを並行に実行するようスケジュールする: L = await asyn...cio . gather ( factorial ( "A" , 2 ), factorial ( "B" , 3 ), factorial ( "C" , 4 ), ) print ( L ) asyncio . run ( main ()) # 期待される出力: # # Ta... - https://man.mtool.work/python/3.14/library/asyncio-task.html
- functools --- 高階関数と呼び出し可能オブジェクトの操作 9526
- functools --- 高階関数と呼び出し可能オブジェクトの操作 ソースコード: Lib/functools.py functools モジュールは、ほかの関数を操作したり返したりする高階関数のためのモジュールです。 一般に、このモジュールではあらゆる呼び出し可能オブジェクトを関数
...ッパーで包んだものです。 古い値を削除する必要がないため、サイズ制限付きの @lru_cache より小さく高速です。 例えば: @cache def factorial ( n ): return n * factorial ( n - 1 ) if n else 1 >>> factorial ( 10 ) # キャッシュ済みの結果がないため、11 回再帰呼び出し...する 3628800 >>> factorial ( 5 ) # 新たな呼び出しをせず、キャッシュ済みの結果を返す 120 >>> factorial ( 12 ) # 2 回新たに再帰呼び出しする。factorial(... - https://man.mtool.work/python/3.14/library/functools.html
- What's New in Python 2.6 9059
- What's New in Python 2.6 著者 : A.M. Kuchling (amk at amk.ca) この記事では、2008 年 10 月 1 日にリリースされた Python 2.6 の新機能を説明します。 リリース日程は PEP 361 に記載されています。 Python 2.6 の主要なテーマは、言語を大幅に再設計する
...入力が 4 の倍数だととっても時間がかかるように仕組んであります。 import time from multiprocessing import Process , Queue def factorial ( queue , N ): "階乗を計算する。" # N が 4 の倍数なら、この関数は大幅に時間がかかる。 if ( N % 4 ) == 0 : time . sleep ( ....* i # 結果をキューへ入れる queue . put ( fact ) if __name__ == '__main__' : queue = Queue () N = 5 p = Process ( target = factorial , args = ( queue , N )) p . start () p . join () result = queue . get () print 'Factorial' , N , '=' , result Queue が fac...コードは Pool を使って 5 個のワーカープロセスへ要求を分配し、結果のリストを取得します。 from multiprocessing import Pool def factorial ( N , dictionary ): "Compute a factorial." ... p = Pool ( 5 ) result = p . map ( factorial , range ( 1 , 1000 , 10 )) for... - https://man.mtool.work/python/3.14/whatsnew/2.6.html
- math --- 数学関数 8448
- math --- 数学関数 このモジュールは、C 標準で定義されたものを含む、一般的な数学関数と定数を提供します。 これらの関数で複素数を使うことはできません。複素数に対応する必要があるならば、 cmath モジュールにある同じ名前の関数を使ってください。ほと
...り値は全て浮動小数点数になります。 Number-theoretic functions comb(n, k) n 個から k 個を、重複なく順序を付けずに選ぶ方法の数 factorial(n) n の階乗 gcd(*integers) 整数引数の最大公約数 isqrt(n) 非負整数 n の整数平方根 lcm(*integers) 整数引数の最小公倍数 perm(...of the arguments are not integers. Raises ValueError if either of the arguments are negative. Added in version 3.8. math. factorial ( n ) Return factorial of the nonnegative integer n . バージョン 3.10 で変更: Floats with integral values (like 5.0 ) are... - https://man.mtool.work/python/3.14/library/math.html
- What's New In Python 3.1 7513
- What's New In Python 3.1 著者 : Raymond Hettinger この記事では Python 3.0 と比較した Python 3.1 の新機能を説明します。 Python 3.1 は 2009 年 6 月 27 日にリリースされました。 PEP 372: 順序付き辞書 通常の Python 辞書は、 key/value ペアを不定の
...例えば次のようになります。 def e (): '''自然対数の底を計算します。 >>> e() 2.7182818284590451 ''' return sum ( 1 / math . factorial ( x ) for x in reversed ( range ( 30 ))) doctest . testmod () ************************************************************... - https://man.mtool.work/python/3.14/whatsnew/3.1.html
- What's New In Python 3.2 7513
- What's New In Python 3.2 著者 : Raymond Hettinger この記事では Python 3.1 と比較した Python 3.2 の新機能を説明します。 Python 3.2 は 2011 年 2 月 20 日にリリースされました。 主な変更点をいくつか取り上げ、例を示します。 すべての詳細については
...のため、ガンマ関数の自然対数を計算する lgamma() 関数があります。 >>> from math import gamma , lgamma >>> gamma ( 7.0 ) # six factorial 720.0 >>> lgamma ( 801.0 ) # log(800 factorial) 4551.950730698041 (Contributed by Mark Dickinson.) abc abc モジュールは @~... - https://man.mtool.work/python/3.14/whatsnew/3.2.html
- What's New In Python 3.8 7351
- What's New In Python 3.8 編集者 : Raymond Hettinger この記事では Python 3.7 と比較した Python 3.8 の新機能を解説します。 Python 3.8 は 2019 年 10 月 14 日にリリースされました。 詳しくは 変更履歴 を参照してください。 概要 -- リリースハイライ
...rt ( s - 1 ) # 正しい 650320426 >>> floor ( sqrt ( s - 1 )) # 誤り 650320427 (Mark Dickinson の貢献による bpo-36887 ) math.factorial() 関数は、引数に int、またはそれに類似するもの以外を受け取らなくなりました。(Pablo Galindo の貢献による bpo-33083 ) mmap m... - https://man.mtool.work/python/3.14/whatsnew/3.8.html
- What's New In Python 3.9 7351
- What's New In Python 3.9 編集者 : Łukasz Langa この記事では Python 3.8 と比較した Python 3.9 の新機能を解説します。 Python 3.9 は 2020 年 10 月 5 日にリリースされました。 詳しくは 変更履歴 を参照してください。 参考 PEP 596 - Python 3.9 リリ
...す。代わりに、 bdist_wheel (wheelパッケージ)を使って下さい。 ( bpo-39586 でのHugo van Kemenadeによる貢献による) 現在の math.factorial() は、非負の整数値を持つ float ( 5.0 など) を受け付け、整数でない値や負の浮動小数点数には ValueError を送出します。 この使... - https://man.mtool.work/python/3.14/whatsnew/3.9.html
PREV
1
NEXT