Python
 Computer >> コンピューター >  >> プログラミング >> Python

Pythonで指数値を見つける方法は?


xの指数値はeのx乗であり、オイラーの数と呼ばれる無理数であり、2.718281に等しいオイラーの定数です。

計算には2つの方法があります。

**演算子の使用

>>> import math
>>> math.e**2 #math.e is defined constant in math module
7.3890560989306495

exp()関数の使用

>>>import math
>>> math.exp(2)
7.38905609893065

  1. Python辞書を値で並べ替える方法は?

    Pythonの標準配布には、コレクションモジュールが含まれています。高性能コンテナデータ型の定義があります。 OrderedDictは、ディクショナリオブジェクトに追加されたエントリの順序を記憶するディクショナリのサブクラスです。順序付けられた辞書を反復処理すると、アイテムはキーが最初に追加された順序で返されます。 >>> from collections import OrderedDict >>> D = {5:fff, 3:ttt, 1:ooo,4:bbb, 2:ddd} >>> OrderedDict(D.items()) Ord

  2. Pythonを使用してファイルを見つける方法は?

    pythonを使用してディレクトリ内のファイルを検索するには、os.walkを使用してディレクトリツリーをウォークし、次のようにファイルを検索します- 例 import os def find_file(file_name, directory_name):     files_found = []     for path, subdirs, files in os.walk(directory_name):         for name in files:       &nbs