Results of 1 - 10 of about 12 for square (0.007 sec.)
- Argparse チュートリアル 14433
- Argparse チュートリアル author : Tshepang Mbambo このチュートリアルでは、 argparse を丁寧に説明します。 argparse は、Python 標準ライブラリの一部であり、おすすめのコマンドライン引数の解析モジュールです。 注釈 標準ライブラリには、コマンドライ
...it 次は、もっと有益なことをしてみませんか?: import argparse parser = argparse . ArgumentParser () parser . add_argument ( "square" , help = "display a square of a given number" ) args = parser . parse_args () print ( args . square ** 2 ) 下記がこのコー...ドを実行した結果です: $ python prog.py 4 Traceback (most recent call last): File "prog.py", line 5, in <module> print(args.square**2) TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int' 上手くいきませんでした。 何も伝えなければ、 ar...ションの値を整数として扱うように伝えましょう: import argparse parser = argparse . ArgumentParser () parser . add_argument ( "square" , help = "display a square of a given number" , type = int ) args = parser . parse_args () print ( args . square ** 2 ) 下... - https://man.mtool.work/python/3.14/howto/argparse.html
- 列挙型 HOWTO 10028
- 列挙型 HOWTO Enum は、ユニークな値に束縛されたシンボル名の集合です。グローバル変数に似ていますが、 repr() がより便利だったり、グルーピングの機能、型安全などいくつかの機能があります。 これらは、限られた選択肢の値の一つを取る変数がある場合に便
...ember . value 1 列挙型メンバーと値の重複 同じ名前の列挙型メンバーを複数持つことはできません: >>> class Shape ( Enum ): ... SQUARE = 2 ... SQUARE = 3 ... Traceback (most recent call last): ... TypeError : 'SQUARE' already defined as 2 しかし、列挙型メン...ます。 A の名前での検索ではメンバー A を返します。 B の名前での検索も、メンバー A を返します: >>> class Shape ( Enum ): ... SQUARE = 2 ... DIAMOND = 1 ... CIRCLE = 3 ... ALIAS_FOR_SQUARE = 2 ... >>> Shape . SQUARE <Shape.SQUARE: 2> >>> Shape . ALIAS_FOR..._SQUARE <Shape.SQUARE: 2> >>> Shape ( 2 ) <Shape.SQUARE: 2> 注釈 すでに定義されている属性と同じ名前のメンバー (一方がメンバーでもう... - https://man.mtool.work/python/3.14/howto/enum.html
- math --- 数学関数 8401
- math --- 数学関数 このモジュールは、C 標準で定義されたものを含む、一般的な数学関数と定数を提供します。 これらの関数で複素数を使うことはできません。複素数に対応する必要があるならば、 cmath モジュールにある同じ名前の関数を使ってください。ほと
...rt for an arbitrary number of arguments. Formerly, only two arguments were supported. math. isqrt ( n ) Return the integer square root of the nonnegative integer n . This is the floor of the exact square root of n , or equivalently the greatest integer...tions, it may be more convenient to have the least integer a such that n ≤ a ², or in other words the ceiling of the exact square root of n . For positive n , this can be computed using a = 1 + isqrt(n - 1) . Added in version 3.8. math. lcm ( * integer... - https://man.mtool.work/python/3.14/library/math.html
- turtle --- タートルグラフィックス 8260
- turtle --- タートルグラフィックス ソースコード: Lib/turtle.py Turtle star 単純な動きを繰り返すプログラムで、タートルは複雑な図形を描けます。 x-y 平面の (0, 0) から動き出す、亀のロボットを想像してください。 import turtle の後に turtle.forwar
...ust exist in the TurtleScreen 's shape dictionary. Initially there are the following shapes: "arrow", "turtle", "circle", "square", "triangle" and "classic". To add shapes, see the Screen method register_shape() . >>> turtle . shape () 'classic' >>> tu...を送出します。 指定された行列に応じて、伸縮率、せん断係数、傾斜角を変更します。 >>> turtle = Turtle () >>> turtle . shape ( "square" ) >>> turtle . shapesize ( 4 , 2 ) >>> turtle . shearfactor ( - 0.5 ) >>> turtle . shapetransform () (4.0, -1.0, -0.0, 2....多角形を、座標ペアのタプルとして返します。 新しい形状や、複合形状の構成要素を定義するために使えます。 >>> turtle . shape ( "square" ) >>> turtle . shapetransform ( 4 , - 1 , 0 , 2 ) >>> turtle . get_shapepoly () ((50, -20), (30, 20), (-50, 20), (-30, -2... - https://man.mtool.work/python/3.14/library/turtle.html
- The Python Profilers 8171
- The Python Profilers Source code: Lib/profile.py and Lib/pstats.py Introduction to the profilers cProfile and profile provide deterministic profiling of Python programs. A profile is a set of statistics that describes how often and for how
...can be probabilistically (on the average) removed. After the profiler is calibrated, it will be more accurate (in a least square sense), but it will sometimes produce negative numbers (when call counts are exceptionally low, and the gods of probabilit... - https://man.mtool.work/python/3.14/library/profile.html
- What's New In Python 3.10 8171
- What's New In Python 3.10 編集者 : Pablo Galindo Salgado この記事では Python 3.9 と比較した Python 3.10 の新機能を解説します。Python 3.10 は2021年10月4日にリリースされました。全詳細については 変更履歴 をご覧ください。 概要 -- リリースハイラ
...。 以前のバージョンの Python では、複数の型の引数を受け取る関数に型ヒントを付けるために typing.Union を使っていました。 def square ( number : Union [ int , float ]) -> Union [ int , float ]: return number ** 2 型ヒントをより簡潔に書けるようになりました。...def square ( number : int | float ) -> int | float : return number ** 2 この新しい構文は isinstance() と issubclass() の第 2 引数でも... - https://man.mtool.work/python/3.14/whatsnew/3.10.html
- Unicode HOWTO 8118
- Unicode HOWTO Release : 1.12 この HOWTO 文書は、文字データの表現のための Unicode 仕様の Python におけるサポートについて論じ、さらに Unicode を使おうというときによく出喰わす多くの問題について説明します。 Unicode 入門 定義 今日のプログラムは広
...TER E WITH ACUTE 1 0bf2 No TAMIL NUMBER ONE THOUSAND 2 0f84 Mn TIBETAN MARK HALANTA 3 1770 Lo TAGBANWA LETTER SA 4 33af So SQUARE RAD OVER S SQUARED 1000.0 カテゴリーコードは文字の性質を略記で表したものです。カテゴリーコードは "Letter"、"Number"、"Punc... - https://man.mtool.work/python/3.14/howto/unicode.html
- dataclasses --- データクラス 8118
- dataclasses --- データクラス ソースコード: Lib/dataclasses.py このモジュールは、 __init__() や __repr__() のような 特殊メソッド を生成し、ユーザー定義のクラスに自動的に追加するデコレーターや関数を提供します。このモジュールは元々、 PEP 557 で
...す。 class Rectangle : def __init__ ( self , height , width ): self . height = height self . width = width @dataclass class Square ( Rectangle ): side : float def __post_init__ ( self ): super () . __init__ ( self . side , self . side ) ただし、基底クラ... - https://man.mtool.work/python/3.14/library/dataclasses.html
- 5. データ構造 8118
- 5. データ構造 この章では、すでに学んだことについてより詳しく説明するとともに、いくつか新しいことを追加します。 5.1. リスト型についてもう少し list 型には、他にもいくつかメソッドがあります。リストオブジェクトのすべてのメソッドを以下に示します
...の条件を満たす要素だけを取り出して部分シーケンスを作ることもできます。 例えば、次のような平方のリストを作りたいとします: >>> squares = [] >>> for x in range ( 10 ): ... squares . append ( x ** 2 ) ... >>> squares [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] この...上書きします。この変数がループ終了後も残ることに注意してください。次のように書けば、副作用なしで平方のリストを計算できます: squares = list ( map ( lambda x : x ** 2 , range ( 10 ))) もしくは、以下でも同じです: squares = [ x ** 2 for x in range ( 10 )] こ...sion fruit ' ] >>> [ weapon . strip () for weapon in freshfruit ] ['banana', 'loganberry', 'passion fruit'] >>> # (number, square) のような2要素のタプルのリストを作る >>> [( x , x ** 2 ) for x in range ( 6 )] [(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (... - https://man.mtool.work/python/3.14/tutorial/datastructures.html
- 6. 式 (expression) 8065
- 6. 式 (expression) この章では、Python の式における個々の要素の意味について解説します。 構文上の注意: この章以降では、 文法の表記法 を字句解析ではなく構文の記述に使います。 構文規則の (選択肢の 1 つの) 形式が次のように記述され、 name : other
...内包表記も暗黙的に非同期になります。 6.2.6. リスト表示 A list display is a possibly empty series of expressions enclosed in square brackets: list_display : "[" [ flexible_expression_list | comprehension ] "]" A list display yields a new list object, the...25, 36, 49, 64, 81] 従って、上の例はおおよそ次のジェネレータ関数を定義して呼び出すことに相当します。 def make_generator_of_squares ( iterator ): for x in iterator : yield x ** 2 make_generator_of_squares ( iter ( range ( 10 ))) 呼び出しにおいて、ジェネ... - https://man.mtool.work/python/3.14/reference/expressions.html